Submission #552087

# Submission time Handle Problem Language Result Execution time Memory
552087 2022-04-22T11:46:15 Z RaresFelix Remittance (JOI19_remittance) C++17
0 / 100
1000 ms 340 KB
#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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Execution timed out 1093 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Execution timed out 1093 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Execution timed out 1093 ms 212 KB Time limit exceeded
17 Halted 0 ms 0 KB -