Submission #795123

#TimeUsernameProblemLanguageResultExecution timeMemory
795123raysh07Remittance (JOI19_remittance)C++17
100 / 100
626 ms36460 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...