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 MN 1000071
#pragma GCC optimize("O3")
using ll = long long;
using namespace std;
ll n, A[MN], B[MN];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; ++i) cin >> A[i] >> B[i];
int ok;
do {
ok = 0;
for(int i = 1; i <= n; ++i) {
if(A[i] > B[i]) {
ll v;
ok = 1, v = (A[i] - B[i] + 1) >> 1;
if(A[i] < (v << 1)) --v;
if(!v) ok = 0;
A[i + 1] += v;
A[i] -= v << 1;
}
}
A[1] += A[n + 1];
A[n + 1] = 0;
} while(ok);
ok = 1;
for(int i = 1; i <= n; ++i) if(A[i] != B[i]) ok = 0;
cout << (ok ? "Yes\n" : "No\n");
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... |