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 f first
#define s second
using namespace std;
long long n;
long long a[1000005],b[1000005];
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
for (int i=0;i<n;i++) cin>>a[i]>>b[i];
long long cnt=50;
while (cnt--){
for (int i=0;i<n;i++){
if (a[i]>b[i]){
long long give=(a[i]-max(0LL,b[i]-1))/2;
if (give>0) a[i]-=give*2;
if (give>0) a[(i+1)%n]+=give;
}
}
}
for (int i=0;i<n;i++){
if (a[i]!=b[i]) {
cout<<"No"<<endl;
return 0;
}
}
cout<<"Yes"<<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... |