Submission #270389

#TimeUsernameProblemLanguageResultExecution timeMemory
270389islingrRemittance (JOI19_remittance)C++17
0 / 100
1 ms384 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]; #pragma GCC optimize ("trapv") 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; // cout << "Yes"; // } 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...