Submission #270394

#TimeUsernameProblemLanguageResultExecution timeMemory
270394islingrRemittance (JOI19_remittance)C++17
100 / 100
264 ms8312 KiB
#include <iostream> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) const int N = 1 << 20; int a[N], b[N]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; rep(i, 0, n) cin >> a[i] >> b[i]; bool fine = false; rep(i, 0, n) if (b[i] != 0) fine = true; if (!fine) { rep(i, 0, n) if (a[i] != 0) return cout << "No", 0; return cout << "Yes", 0; } bool flow = true; while (flow) { flow = false; rep(i, 0, n) { if (a[i] <= b[i]) continue; flow = true; int del = (a[i] - b[i] + 1) / 2; a[i] -= 2 * del; a[(i + 1) % n] += del; } } cout << ([&]() { rep(i, 0, n) if (a[i] != b[i]) return false; return true; }() ? "Yes" : "No"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...