Submission #904826

# Submission time Handle Problem Language Result Execution time Memory
904826 2024-01-12T09:17:34 Z vjudge1 Remittance (JOI19_remittance) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define fast ios::sync_with_stdio(false), cin.tie(NULL)

const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int SQ = 350;
const int LG = 23;

signed main()
{
    fast;
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    bool f1 = 0, f2 = 0;
    for (int i = 0; i < n; i++)
        if (a[i])
            f1 = 1;
    for (int i = 0; i < n; i++)
        if (b[i])
            f2 = 1;
    if (!f1 && !f2)
        return cout << "YES", 0;
    if (f1 ^ f2)
        return cout << "NO", 0;
    while (true)
    {
        bool good = 1;
        for (int i = 0; i < n; i++)
            if (a[i] > b[i])
                good = 0;
        if (good)
            break;
        for (int i = 0; i < n; i++)
            if (a[i] > b[i])
            {
                int x = (a[i] - b[i] + 1) >> 1;
                a[i] -= x * 2;
                a[(i + 1) % n] += x;
            }
    }
    bool good = 1;
    for (int i = 0; i < n; i++)
        if (a[i] != b[i])
            good = 0;
    if (good)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -