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>
using namespace std;
int main() {
int n; cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; ++i)cin >> a[i] >> b[i];
for(int j = 0; j < 50; ++j){
for(int i = 0; i < n; ++i){
if(a[i] > b[i]){
a[(i+1)%n]+=(a[i]-b[i]+1)>>1;
a[i]-=(((a[i]-b[i]+1)>>1)<<1);
if(a[i] < 0){a[(i+1)%n]--;a[i]+=2;}
}
}
}
cout << (a==b ? "Yes\n" : "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... |