Submission #979947

#TimeUsernameProblemLanguageResultExecution timeMemory
979947peterandvoiRemittance (JOI19_remittance)C++17
100 / 100
166 ms36488 KiB
#include <bits/stdc++.h> using namespace std; #ifdef ngu #include "debug.h" #else #define debug(...) 42 #endif using ll = int64_t; int main() { ios::sync_with_stdio(false); cin.tie(0); #ifdef ngu freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); #endif int n; cin >> n; vector<ll> a(n), b(n); for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; } if (*max_element(b.begin(), b.end()) == 0) { cout << (*max_element(a.begin(), a.end()) > 0 ? "No" : "Yes"); exit(0); } bool okay = true; while (okay) { okay = false; for (int i = 0; i < n; ++i) { if (a[i] > b[i]) { ll x = (a[i] - b[i] + 1) / 2; a[i] -= x * 2; a[(i + 1) % n] += x; okay = true; } } } okay = true; for (int i = 0; i < n; ++i) { okay &= (a[i] == b[i]); } cout << (okay ? "Yes" : "No"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...