Submission #431649

# Submission time Handle Problem Language Result Execution time Memory
431649 2021-06-17T14:01:06 Z kostia244 Remittance (JOI19_remittance) C++17
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 16;
int n, a[N], b[N];
queue<int> q;
void add(int i, int x) {
    a[i] += x;
    if(a[i] > b[i]+1)
        q.push(i);
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        if(a[i] > b[i])
            q.push(i);
    }
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        if(a[v] == b[v]) continue;
        add((v+1)%n, (a[v]-b[v])/2);
        a[v] -= 2*((a[v]-b[v])/2);
    }
    int ok = 1;
    for(int i = 0; i < n; i++) ok &= a[i] == b[i];
    cout << (ok?"Yes":"No") << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -