#include<iostream>
#include<queue>
using namespace std;
int t[2000000][2];
int jest[2000000];
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int n,x,y;
cin>>n;
queue<int> kolejka;
for(int i=0;i<n;i++)
{
cin>>x>>y;
t[i][0]=x;
t[i][1]=y;
if(x>y+1)
{
kolejka.push(i);
jest[i]=1;
}
}
while(!kolejka.empty())
{
x=kolejka.front();
kolejka.pop();
jest[x]=0;
int oddaje=t[x][0]-t[x][1];
t[(x+1)%n][0]+=oddaje/2;
if(oddaje%2==1)
t[x][0]=t[x][1]+1;
else t[x][0]=t[x][1];
if(t[(x+1)%n][0]>t[(x+1)%n][1]+1 && jest[(x+1)%n]==0)
kolejka.push((x+1)%n);
}
int k=0;
for(int i=0;i<n;i++)
if(t[i][0]!=t[i][1])
k=1;
if(k==0)
cout<<"Yes";
else cout<<"No";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |