Submission #145985

#TimeUsernameProblemLanguageResultExecution timeMemory
145985fedoseevtimofeyRemittance (JOI19_remittance)C++14
100 / 100
379 ms36600 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n; cin >> n; vector <int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; while (true) { bool fl = false; for (int i = 0; i < n; ++i) { if (a[i] > b[i] + 1) { int x = a[i] - b[i]; x -= x % 2; a[i] -= x; a[(i + 1) % n] += x / 2; fl = true; } } if (!fl) { for (int i = 0; i < n; ++i) { if (a[i] == b[i] + 1 && a[i] >= 2) { a[i] -= 2; a[(i + 1) % n] += 1; fl = true; } } } if (!fl) break; } if (a == b) cout << "Yes\n"; else cout << "No\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...