This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;
ll a[1000000], b[1000000];
int main() {
iostream::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
FOR(i, 0, n) cin >> a[i] >> b[i];
if (!accumulate(b, b + n, 0))
return cout << (accumulate(a, a + n, 0) ? "No" : "Yes"), 0;
bool possible = true;
while (possible) {
possible = false;
FOR(i, 0, n) {
if (a[i] > b[i]) {
a[(i + 1) % n] += (a[i] - b[i] + 1) >> 1;
a[i] -= ((a[i] - b[i] + 1) >> 1) << 1;
possible = true;
}
}
}
bool ans = true;
FOR(i, 0, n) ans &= (a[i] == b[i]);
cout << (ans ? "Yes" : "No");
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |