Submission #502904

# Submission time Handle Problem Language Result Execution time Memory
502904 2022-01-06T18:09:46 Z tengiz05 Remittance (JOI19_remittance) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    std::cin >> n;
    
    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i];
    }
    
    std::function<void()> dfs = [&]() {
        for (int _ = 0; _ < n; _++) {
            if (a == b) {
                std::cout << "Yes\n";
                std::exit(0);
            }
            int p = 0;
            for (int i = 0; i < n; i++) {
                int j = (p + 1) % n;
                int d = a[p] - b[p];
                if (d < 0) {
                    p = j;
                    continue;
                }
                if (d == 1 && a[p] > 1) {
                    d++;
                }
                d /= 2;
                a[p] -= 2 * d;
                a[j] += d;
                p = j;
            }
        }
        std::cout << "No\n";
        std::exit(0);
    };
    
    dfs();
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 0 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 -