Submission #413721

#TimeUsernameProblemLanguageResultExecution timeMemory
413721MagiRemittance (JOI19_remittance)C++14
0 / 100
1 ms204 KiB
#include <iostream> using namespace std; int n, a[25], b[25]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int i=1; i<=n; i++) cin >> a[i] >> b[i]; bool ok = true; while(ok){ ok = false; for(int i=1; i<=n; i++) if(a[i] > b[i] && a[i] > 1){ ok = true; int dif = (a[i] - b[i] + 1) / 2; if(i == n) a[1] += dif; else a[i+1] += dif; a[i] -= 2 * dif; break; } } ok = true; for(int i=1; i<=n; i++) if(a[i] != b[i]) ok = false; if(ok) cout << "Yes" << '\n'; else cout << "No" << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...