Submission #336592

# Submission time Handle Problem Language Result Execution time Memory
336592 2020-12-15T22:34:01 Z aryan12 Remittance (JOI19_remittance) C++17
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int suma = 0, sumb = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        suma += a[i];
        sumb += b[i];
    }
    if(suma < sumb) {
        cout << "No" << endl;
        return 0;
    }
    if(suma == sumb) {
        for(int i = 0; i < n; i++) {
            if(a[i] != b[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    bool f = true;
    while(f) {
        f = false;
        for(int i = 0; i < n; i++) {

            int extra = (a[i] - b[i]) / 2;
            if(extra == 0 || b[i] > a[i])
                continue;
            a[i] -= extra * 2;
            a[(i + 1) % n] += extra;
            f = true;
        }
        /*for(int i = 0; i < n; i++) {
            cout << a[i] << " ";
        }
        cout << endl;*/
    }
    /*for(int i = 0; i < n; i++) {
        cout << a[i] << " " << b[i] << endl;
    }*/
    for(int i = 0; i < n; i++) {
        if(a[i] != b[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 1 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -