Submission #163652

#TimeUsernameProblemLanguageResultExecution timeMemory
163652combi1k1Remittance (JOI19_remittance)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define FOR(i,a,b) for(int i = a ; i < b ; ++i) int a[1000000]; int b[1000000]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; FOR(i,0,n) cin >> a[i] >> b[i]; bool alter; do { alter = 0; FOR(i,0,n) { int j = (i + 1) % n; if (a[i] > b[i]) { int x = max(1ll,(a[i] - b[i]) / 2); a[i] -= x * 2; a[j] += x; alter = 1; } } if(!alter) break; } while (alter); FOR(i,0,n) if (a[i] != b[i]) return 0 * puts("No"); cout << "Yes"; } /* 5 0 0 1 0 2 3 3 3 4 0 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...