| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1275634 | monaxia | Remittance (JOI19_remittance) | C++20 | 1 ms | 576 KiB | 
#include <bits/stdc++.h>
#include <ext/random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define pb push_back
#define ppb pop_back
#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define vektor vector
using namespace std;
// using namespace __gnu_pbds; 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr ull Mod = 1e9 + 7;
constexpr ull Mod2 = 1 + 7 * 17 * (1 << 23);
constexpr ull sqr = 320;
constexpr ld eps = 1e-9;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll l, ll r) {if(l <= r) return uniform_int_distribution <ll> (l, r)(rng); return -1;} 
int a[1000005], b[1000005];
void solve(){
    int n;
    cin >> n;
    priority_queue <pair <int, int>> pq;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i] >> b[i];
        if(a[i] > b[i] + 1) pq.push({a[i] - b[i], i});
    }
    while(!pq.empty()){
        int val = pq.top().fr, i = pq.top().sc;
        pq.pop();
        if(val == 1) continue;
        int add = val / 2;
        a[i] -= add * 2;
        int next = i + 1;
        if(i == n) next = 1;
        a[next] += add;
        if(a[next] > b[next] + 1) pq.push({a[next] - b[next], next});
    }
    for(int i = 1; i <= n; i ++){
        if(a[i] != b[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}
int main(){
    // cout << 1; return 0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    if(fopen("TABLE.inp", "r")){
        freopen("TABLE.inp", "r", stdin);
        freopen("TABLE.out", "w", stdout);
    }
    ll t = 1;
    // cin >> t;
    while(t --){
        solve();
        cout << "\n";
    }
    cerr << "Code time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
// Whose eyes are those eyes?
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
