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 <iostream>
using namespace std;
const int nmax=1000*1000+5;
long long a[nmax],b[nmax];
long long sumA,sumB;
int n,i;
int main()
{
ios_base::sync_with_stdio(false);
cin>>n;
for(i=0;i<n;i++)
{
cin>>a[i]>>b[i];
sumA+=a[i];sumB+=b[i];
}
if(!sumB)
{
if(!sumA) cout<<"Yes";
else cout<<"No";
return 0;
}
for(bool change=1;change;)
{
change=0;
for(i=0;i<n;i++)
if(a[i]>b[i])
{
long long dif=(a[i]-b[i]+1)/2;
a[i]-=2*dif;
a[(i+1)%n]+=dif;
change=1;
}
}
bool bun=1;
for(i=0;i<n;i++)
bun&=(a[i]==b[i]);
if(bun) cout<<"Yes";
else cout<<"No";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |