| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 162753 | Swan | 송금 (JOI19_remittance) | C++14 | 3 ms | 444 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("output.txt","w",stdout)
#define double long double
#define int long long
using namespace std;
typedef long long ll;
vector<pair<int,int> > v;
bool check(){
    for(int i(0); i < v.size();i++){
        if(v[i].first != v[i].second)return 0;
    }
    return 1;
}
bool solve(){
    for(int i(0); i < v.size();i++){
        int to = (i+1)%v.size();
        int can = v[i].first-v[i].second;
        if(can <= 0)continue;
        can/=2;
        if(can == 0)continue;
        v[to].first+=can;
        v[i].first-=2*can;
        //cerr << i+1 << ' ' << can << endl;
        return 1;
    }
    return 0;
}
main()
{
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for(int i(0); i < n;i++){
        int a,b; cin >> a >> b;
        v.push_back({a,b});
    }
    //cerr << '\n';
    while(1){
        bool f = solve();
        if(!f)break;
    }
    if(!check())cout << "No";
    else cout << "Yes";
    return 0;
}
/*
3
1 3 3
4 6 3
7 9 3
*/
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... | ||||
