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];
bool possible = true;
while (possible) {
possible = false;
for (int i = n - 1; ~i; i--) {
if (a[i] > b[i]) {
a[(i + 1) % n] += (a[i] - b[i] + 1) / 2;
a[i] -= (a[i] - b[i] + 1) / 2 * 2;
}
}
FOR(i, 0, n) possible |= a[i] > b[i];
}
bool ans = true;
FOR(i, 0, n) ans &= (a[i] == b[i]);
if (ans) cout << "Yes";
else cout << "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... |