Submission #904931

#TimeUsernameProblemLanguageResultExecution timeMemory
904931RomicroRemittance (JOI19_remittance)C++17
0 / 100
1 ms500 KiB
#include <iostream> #define endl '\n' using namespace std; const int MAXN = 1e5+100; int n; int cnt; int a[MAXN], b[MAXN]; int main(){ ios::sync_with_stdio(0);cin.tie(0); cin >> n; for(int i=0; i<n; i++) cin >> a[i] >> b[i]; int p=0; int mn = 1e9; for(int i=0; i<n;i++){ if(a[i] - b[i] < mn){ mn = a[i] - b[i]; p = i; } } while(cnt < n){ if(a[p] <= b[p]){ cnt++; p++; continue; } int tmp = (a[p] - b[p])/2; if(tmp) cnt = 0; a[p] -= tmp*2; p = (p+1)%n; a[p] += tmp; } bool flg = true; for(int i=0; i<n; i++) if(a[i] != b[i]) flg = false; if(flg) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...