Submission #674199

#TimeUsernameProblemLanguageResultExecution timeMemory
674199MohamedFaresNebiliRemittance (JOI19_remittance)C++14
100 / 100
441 ms20804 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9 + 7; int N, A[1000001], B[1000001]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int l = 0; l < N; l++) cin >> A[l] >> B[l]; for(int _ = 0; _ < 30; _++) { bool ok = true; for(int l = N - 1; l >= 0; l--) { if(A[l] < B[l]) { int C = min(B[l] - A[l], (A[(l - 1 + N) % N])); A[l] += C; A[(l - 1 + N) % N] -= 2 * C; ok = false; } } for(int l = 0; l < N; l++) { if(A[l] > B[l]) { int C = min(A[l] / 2, (A[l] - B[l] + 1) / 2); A[l] -= 2 * C; A[(l + 1) % N] += C; ok = false; } } if(ok) { cout << "Yes\n"; return 0; } } cout << "No\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...