Submission #436580

# Submission time Handle Problem Language Result Execution time Memory
436580 2021-06-24T16:17:24 Z dariasc Remittance (JOI19_remittance) C++14
0 / 100
1 ms 292 KB
#include <bits/stdc++.h>
using namespace std;

int bad() {
    cout << "No\n";
    return 0;
}

int main() {
    int n;
    cin >> n;
    int a[n], b[n];

    int peak = -1;
    int peak_index = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] > peak) {
            peak = a[i];
            peak_index = i;
        }
    }
    rotate(a, a + peak_index, a + n);
    rotate(b, b + peak_index, b + n);

    for (int i = 0; i < n-1; i++) {
        if (a[i] < b[i]) {
            return bad();
        }

        int diff = a[i] - b[i];
        if (diff % 2 == 1) {
            return bad();
        }

        a[i] -= diff;
        a[i+1] += diff/2;
    }

    if (a[n-1] == b[n-1]) {
        cout << "Yes\n";
    } else {
        return bad();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -