제출 #197273

#제출 시각아이디문제언어결과실행 시간메모리
197273loK10송금 (JOI19_remittance)C++17
0 / 100
2 ms256 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        c[i] = a[i] - b[i];
    }
    for(int k = 0; k < 40; k++){
        for(int i = 0; i < n; i++){
            if(c[i] > 0){
                int delta = min(a[i] / 2, (c[i] + 1) / 2);
                a[i] -= 2 * delta;
                c[i] -= 2 * delta;
                a[(i + 1) % n] += delta;
                c[(i + 1) % n] += delta;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(c[i]){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";


    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...