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 ll long long
#define all(a) (a).begin(), (a).end()
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
//#define cin fin
//#define cout fout
using namespace std;
//ifstream fin("file.in");
//ofstream fout("file.out");
const int nmax=1e3+5;
const int mod=1e9+7;
const int mod1=998244353;
int n,a[1000005],b[1000005];
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
for(int i=1;i<=n;i++) cin >> a[i] >> b[i];
bool unch=false;
for(int i=1;i<=n;i++){
if(a[i]>b[i] && a[i]>=2){
unch=true;
int x=a[i]-b[i];
a[i]=b[i];
if(x%2==1 && a[i]>=1){
a[i]--;
x++;
}
else if(x%2==1){
a[i]++;
}
int j=i+1;
if(i==n) j=1;
x/=2;
a[j]+=x;
}
if(unch==true && i==n){ i=0; unch=false; }
}
string ans="Yes";
for(int i=1;i<=n;i++){
if(a[i]!=b[i]) ans="No";
}
rc(ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |