Submission #147781

#TimeUsernameProblemLanguageResultExecution timeMemory
147781Bodo171Remittance (JOI19_remittance)C++14
100 / 100
349 ms36420 KiB
#include <iostream> using namespace std; const int nmax=1000*1000+5; long long a[nmax],b[nmax]; long long sumA,sumB; int n,i; int main() { ios_base::sync_with_stdio(false); cin>>n; for(i=0;i<n;i++) { cin>>a[i]>>b[i]; sumA+=a[i];sumB+=b[i]; } if(!sumB) { if(!sumA) cout<<"Yes"; else cout<<"No"; return 0; } for(bool change=1;change;) { change=0; for(i=0;i<n;i++) if(a[i]>b[i]) { long long dif=(a[i]-b[i]+1)/2; a[i]-=2*dif; a[(i+1)%n]+=dif; change=1; } } bool bun=1; for(i=0;i<n;i++) bun&=(a[i]==b[i]); if(bun) cout<<"Yes"; else cout<<"No"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...