Submission #197630

#TimeUsernameProblemLanguageResultExecution timeMemory
197630IOrtroiiiRemittance (JOI19_remittance)C++14
100 / 100
361 ms36516 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); int N; cin >> N; vector<ll> A(N), B(N); for (int i = 0; i < N; ++i) { cin >> A[i] >> B[i]; } while (true) { bool changed = false; for (int i = 0; i < N; ++i) { int j = (i + 1) % N; if (A[i] - B[i] >= 2) { ll z = (A[i] - B[i]) / 2; A[i] -= 2 * z; A[j] += z; changed = true; } else if (A[i] - B[i] == 1 && A[i] > 1) { A[i] -= 2; A[j] += 1; changed = true; } } if (!changed) break; } for (int i = 0; i < N; ++i) if (A[i] ^ B[i]) return cout << "No\n",0; return cout << "Yes\n",0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...