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>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
#define int long long
const int N = (int)1e6+10;
int n, a[N], b[N];
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n; int ok = 1;
for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
int xd = n+100000, i = 1;
while(xd--){
int nx = (i+1==n?0:i+1);
int tot = (a[i]-b[i]+1)/2;
if(a[i]>b[i]) a[nx]+=tot,a[i]-=tot*2;
i = nx;
}
for(int i = 0; i < n; i++) ok&=(a[i]==b[i]);
cout << (ok?"Yes":"No") << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |