제출 #1362694

#제출 시각아이디문제언어결과실행 시간메모리
1362694iamhereforfun송금 (JOI19_remittance)C++20
0 / 100
1 ms344 KiB
// Starcraft 2 enjoyer //

#include <bits/stdc++.h>

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

#define LSOne(X) ((X) & -(X))

const int N = 2e6 + 5;
const int M = 1e6 + 5;
const int B = 18;
const long long K = 2;
const int LG = 20;
const int INF = 1e9 + 5;
const int P = 31;
const int MOD = 1e9 + 7;
const int nx[] = {0, 1, 0, -1}, ny[] = {-1, 0, 1, 0};

long long n, a[N], b[N];

inline void solve()
{
    cin >> n;
    for (int x = 0; x < n; x++)
    {
        cin >> a[x] >> b[x];
    }
    for (int y = 0; y < 32; y++)
    {
        for (int x = 0; x < n; x++)
        {
            if (a[x] > b[x])
            {
                if ((a[x] - b[x]) % 2 == 0)
                {
                    a[(x + 1) % n] += (a[x] - b[x]) / 2;
                    a[x] = b[x];
                }
            }
        }
    }
    for (int x = 0; x < n; x++)
    {
        if (a[x] != b[x])
        {
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…