LoginSignup
0
0

More than 3 years have passed since last update.

AtCoder 生活111日目

Posted at

前回

111日目

今日は、灰色を2問と茶色2問を解きました。

問題 難易度 自力で解けた かかった時間
ABC044 B 12分56秒
AGC014 A 77分2秒
ABC131 D 13分43秒
ARC081 C 123分14秒

ABC044_B


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    char r = s[0];
    int c = 1;
    bool ok = true;
    for(int i = 1;i < s.size();i++){
        if(s[i] == r)c++;
        else {
            if(c % 2 != 0)ok = false;
            c = 1;
            r = s[i];
        }
    }
    if(c % 2 != 0)ok = false;
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}

解くのにかかった時間:12分56秒

AGC014_A


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    rep(i,100000){
        if(a%2 || b%2 || c%2 ){
            cout << i << endl;
            return 0;
        }
        ll x = a/2;
        ll y = b/2;
        ll z = c/2;
        a = x+y;
        b = y+z;
        c = z+x;
    }
    cout << -1 << endl;
}

解くのにかかった時間:77分2秒
感想:なかなかに理解が進まなかった。

ABC131_D


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<pii> x(n);
    rep(i,n){
        int a,b:
        cin >> a >> b;
        x[i].first = b;
        x[i].second = a;
    }
    sort(x.begin(),x.end());
    ll t = 0;
    rep(i,n){
        t += x[i].second;
        if(t > x[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

解くのにかかった時間:13分43秒

ARC081_C


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    map<int,int> mp;
    rep(i,n){
        int s;
        cin >> s;
        mp[s]++;
        if(mp[s] == 2){
            mp[s] = 0;
            v.push_back(s);
        }
    }
    sort(v.rbegin(),v.rend());
    ll ans = 0;
    if(2 <= v.size())ans = 1LL*v[0]*v[1];
    cout << ans << endl;
}

解くのにかかった時間:123分14秒
感想:mapの使い方を忘れていた。

最後に

ABC以外がレートより少し難しくなってきた気がする

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0