Submission #1331859

#TimeUsernameProblemLanguageResultExecution timeMemory
1331859kawhietRemittance (JOI19_remittance)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif

#define int long long

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    int t = 1000;
    while (t--) {
        for (int i = 0; i < n; i++) {
            int j = (i + 1) % n;
            if (a[i] > b[i]) {
                a[j] += (a[i] - b[i] + 1) / 2;
                a[i] -= (a[i] - b[i] + 1) / 2 * 2;
            }
        }
    }
    cout << (a == b ? "Yes" : "No") << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...