This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 16;
int n, a[N], b[N];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
for(int z = 100; z--;){
for(int i = 0; i+1 < n; i++) {
if(a[i] > b[i]) {
a[i+1] += (a[i]-b[i]+1)/2;
a[i] -= 2*((a[i]-b[i]+1)/2);
}
}
if(a[n-1] > b[n-1]) {
a[0] += (a[n-1]-b[n-1]+1)/2;
a[n-1] -= 2*((a[n-1]-b[n-1]+1)/2);
}
}
int ok = 1;
for(int i = 0; i < n; i++) ok &= a[i] == b[i];
cout << (ok?"Yes":"No") << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |