Submission #254702

#TimeUsernameProblemLanguageResultExecution timeMemory
254702dolphingarlicRemittance (JOI19_remittance)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define FOR(i, x, y) for (ll i = x; i < y; i++) typedef long long ll; using namespace std; ll a[1000000], b[1000000]; int main() { iostream::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; FOR(i, 0, n) cin >> a[i] >> b[i]; bool possible = true; while (possible) { possible = false; for (int i = n - 1; ~i; i--) { if (a[i] > b[i]) { a[(i + 1) % n] += (a[i] - b[i] + 1) / 2; a[i] -= (a[i] - b[i] + 1) / 2 * 2; } } FOR(i, 0, n) possible |= a[i] > b[i]; } bool ans = true; FOR(i, 0, n) ans &= (a[i] == b[i]); if (ans) cout << "Yes"; else cout << "No"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...