Submission #163653

#TimeUsernameProblemLanguageResultExecution timeMemory
163653combi1k1Remittance (JOI19_remittance)C++14
100 / 100
360 ms36488 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]; for(bool alter = 1 ; alter ;) { alter = 0; FOR(i,0,n) { int j = (i + 1) % n; if (a[i] > 1 && a[i] > b[i]) { int x = max(1ll,(a[i] - b[i]) / 2); a[i] -= x * 2; a[j] += x; alter = 1; } } } 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...