Submission #552087

#TimeUsernameProblemLanguageResultExecution timeMemory
552087RaresFelixRemittance (JOI19_remittance)C++17
0 / 100
1093 ms340 KiB
#include <bits/stdc++.h> #define MN 1000071 #pragma GCC optimize("O3") using ll = long long; using namespace std; ll n, A[MN], B[MN]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; ++i) cin >> A[i] >> B[i]; int ok; do { ok = 0; for(int i = 1; i <= n; ++i) { if(A[i] > B[i]) { ll v; ok = 1, v = (A[i] - B[i] + 1) >> 1; if(A[i] < (v << 1)) --v; A[i + 1] += v; A[i] -= v << 1; } } A[1] += A[n + 1]; A[n + 1] = 0; } while(ok); ok = 1; for(int i = 1; i <= n; ++i) if(A[i] != B[i]) ok = 0; cout << (ok ? "Yes\n" : "No\n"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...