Submission #233550

#TimeUsernameProblemLanguageResultExecution timeMemory
233550aggu_01000101Remittance (JOI19_remittance)C++14
0 / 100
5 ms512 KiB
#include <bits/stdc++.h> #define INF 10000000000000000 #define MOD 1000000017 #define mid(l, u) ((l+u)/2) #define rchild(i) (i*2 + 2) #define lchild(i) (i*2 + 1) #define int long long using namespace std; signed main(){ int n; cin>>n; int e[n]; for(int i =0 ;i<n;i++){ int a, b; cin>>a>>b; e[i] = (a-b); } int carry = 0; int lastchange = 0; int curriter = 0; for(int i = 0;true;i++, i%=n){ int b = e[i]; //cout<<i<<" "<<b<<" "<<carry<<endl; e[i]+=carry; carry = max((int)0, e[i]); if(carry%2) carry--; e[i]-=carry; carry/=2; curriter++; if(e[i]!=b) lastchange = curriter; if((curriter - lastchange)>n) break; } bool diff = false; for(int i = 0;i<n;i++) if(e[i]!=0) diff = true; if(diff) cout<<"No"<<endl; else cout<<"Yes"<<endl; } //l, mid(l, r) || l+1, r //
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...