Submission #756310

#TimeUsernameProblemLanguageResultExecution timeMemory
756310hanifchdnRemittance (JOI19_remittance)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define fi first #define se second int a[1000005], b[1000005]; bool vis[1000005]; queue<int> q; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (a[i] - b[i] >= 2) vis[i] = 1, q.push(i); } while (!q.empty()) { int x = q.front(); q.pop(); int tmp = a[x] - b[x]; vis[x] = 0, a[(x + 1) % n] += tmp / 2, a[x] = b[x] + (tmp % 2); if (!vis[(x + 1) % n] and a[(x + 1) % n] - b[(x + 1) % n] >= 2) vis[(x + 1) % n] = 1, q.push((x + 1) % n); } bool ans = 1; for (int i = 0; i < n; i++) if (a[i] != b[i]) ans = 0; if (ans) 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...