Submission #158532

#TimeUsernameProblemLanguageResultExecution timeMemory
158532bicsiRemittance (JOI19_remittance)C++14
100 / 100
332 ms36396 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<long long> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; int ch = 1; while (ch--) { for (int i = 0; i < n; ++i) { if (a[i] > b[i]) { long long take = (a[i] - b[i]) / 2; a[i] -= 2 * take; if (a[i] > b[i] && a[i] > 1) { a[i] -= 2; take += 1; } int j = (i == n - 1 ? 0 : i + 1); a[j] += take; if (take > 0) ch = 1; } } } for (int i = 0; i < n; ++i) { if (a[i] != b[i]) { cout << "No\n"; return 0; } } cout << "Yes\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...