# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674199 | MohamedFaresNebili | Remittance (JOI19_remittance) | C++14 | 441 ms | 20804 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |