Submission #1159040

#TimeUsernameProblemLanguageResultExecution timeMemory
1159040fryingducRemittance (JOI19_remittance)C++20
100 / 100
117 ms8264 KiB
#include "bits/stdc++.h" using namespace std; #ifdef duc_debug #include "bits/debug.h" #else #define debug(...) #endif void solve() { int n; cin >> n; vector<int> a(n), b(n); int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; sum += b[i]; } if (sum == 0) { for (int i = 0; i < n; ++i) { if (a[i]) { cout << "No"; return; } } cout << "Yes"; return; } while (true) { bool flag = 0; for (int i = 0; i < n; ++i) { if (a[i] > b[i]) { flag = 1; a[(i + 1) % n] += (a[i] - b[i] + 1) / 2; a[i] -= (a[i] - b[i] + 1) / 2 * 2; } } if (!flag) break; } for (int i = 0; i < n; ++i) { if (a[i] != b[i]) { cout << "No"; return; } } cout << "Yes"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...