제출 #806802

#제출 시각아이디문제언어결과실행 시간메모리
806802LucaIlie송금 (JOI19_remittance)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e6;
const long long INF = 1e17;
int a[MAX_N], b[MAX_N];

int main() {
    int n;

    cin >> n;
    for ( int i = 0; i < n; i++ )
        cin >> a[i] >> b[i];

    /*for ( int i = 0; i < n; i++ ) {
        int j = (i - 1 + n) % n, it = 0;
        long long x = 0;
        while ( x < INF && j != i && a[i] + (x / (1 << ((i - j + n) % n))) < b[i] ) {
            x *= 2;
            if ( b[j] - a[j] > 0 )
                x += b[j] - a[j];
            it++;
        }
    }*/
    for ( int p = 0; p < 1000; p++ ) {
        for ( int i = 0; i < n; i++ ) {
            if ( a[i] > b[i] ) {
                int x = (a[i] - b[i]) / 2;
                a[(i + 1) % n] += x;
                a[i] -= 2 * x;
            }
        }
    }

    bool ans = true;
    for ( int i = 0; i < n; i++ )
        ans &= (a[i] == b[i]);
    cout << (ans ? "YES" : "NO");

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