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;
#define int long long
const int MAX_N = 1e6;
int n,a[MAX_N], b[MAX_N];
signed main(){
cin>>n;
for(int i = 0; i<n; i++){
cin>>a[i];
cin>>b[i];
}
for(int turn = 0; turn<35; turn++){
for(int i = 0; i<n; i++){
int dif= (a[i]-b[i]+1)/2;
if(dif>0 && a[i]-2*dif>=0){
a[i]-=2*dif;
a[(i+1)%n] += dif;
}
}
}
bool ok = true;
for(int i = 0; i<n; i++){
ok &= a[i]==b[i];
}
if(ok){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |