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 N 1000020
using namespace std;
int n, a[N], b[N], t[N];
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
for(int i = 0; i < n; i++)
{
cin>>a[i]>>b[i];
t[i] = a[i] - b[i];
}
for(int c = 0; c < 40; c++)
{
for(int i = 0; i < n; i++)
{
if(t[i] > 0)
{
int dt = min(a[i]/2, (t[i] + 1)/2);
t[i] -= 2*dt;
a[i] -= 2*dt;
t[(i + 1)%n] += dt;
a[(i + 1)%n] += dt;
}
}
}
for(int i = 0; i < n; i++) if(t[i])
{
cout<<"No\n";
return 0;
}
cout<<"Yes\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... |