Submission #525477

# Submission time Handle Problem Language Result Execution time Memory
525477 2022-02-11T18:46:53 Z PiejanVDC Remittance (JOI19_remittance) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

signed main() {
    int n; cin>>n;
    vector<pair<int64_t,int64_t>>v(n);
    bool a = 0,b = 0;
    for(auto &z : v) {
        cin>>z.first>>z.second;
        if(z.first != 0) a = 1;
        if(z.second != 0) b = 1;
    }
    if(!a) {
        if(b) cout << "No"; else cout << "Yes";
        return 0;
    }
    for(int i = 0 ; i < n ; i++) {
        for(int ii = 0 ; ii < n-1 ; ii++) {
            int64_t d = max(0LL, (v[ii].first - v[ii].second)/2LL);
            v[ii].first -= 2LL*d;
            v[ii+1].first += d;
        }
        int d = max(0LL, (v[n-1].first - v[n-1].second)/2LL);
            v[n-1].first -= 2LL*d;
            v[0].first += d;
    }
    bool ok = 1;
    for(int i = 0 ; i < n ; i++) {
        if(v[i].first != v[i].second)
            ok = 0;
    }
    cout << (ok ? "Yes" : "No");
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 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 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 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 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -