제출 #564211

#제출 시각아이디문제언어결과실행 시간메모리
5642114fecta송금 (JOI19_remittance)C++17
100 / 100
344 ms36560 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)

const int MN = 1000005;

int n;
pii a[MN * 2];

int32_t main() {
    boost();

    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i].f >> a[i].s;
    for (int t = 0; t < 32; t++) { //wtf???
        for (int i = 0; i < n; i++) {
            if (a[i].s < a[i].f) {
                int d = (a[i].f - a[i].s + 1) / 2;
                if (a[i].f < d * 2) continue;
                a[i].f -= d * 2;
                a[(i + 1) % n].f += d;
            }
        }
    }

    for (int i = 0; i < MN * 2; i++) if (a[i].f != a[i].s) return 0 * printf("No\n");
    printf("Yes\n");

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