#include <bits/stdc++.h>
using namespace std;
const int nx=1e6+5;
int n, a[nx], b[nx], lst, cnt;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=0; i<n; i++) cin>>a[i]>>b[i];
while (1)
{
for (int i=0; i<n; i++)
{
lst++;
if (a[i]>b[i]+1) a[(i+1)%n]+=(a[i]-b[i])/2, a[i]-=((a[i]-b[i])/2)*2, lst=0;
if (lst==n)
{
for (int j=0; j<n; j++)
{
if (a[j]!=b[j])
{
for (int k=0; k<n; k++) if (b[k]>=a[k]||b[k]==0) return cout<<"No", 0;
return cout<<"Yes", 0;
}
}
return cout<<"Yes", 0;
}
}
}
}
/*
5
0 0
0 0
0 0
0 1
16 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |