이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
long long a=0,b=0;
for(int i=0;i<n;i++)
{
cin>>x>>y;
t[i][0]=x;
t[i][1]=y;
a+=x;
b+=y;
if(x>y)
{
kolejka.push(i);
jest[i]=1;
}
}
if(a!=0 && b==0)
{
cout<<"No";
return 0;
}
while(!kolejka.empty())
{
x=kolejka.front();
kolejka.pop();
jest[x]=0;
int oddaje=t[x][0]-t[x][1]+1;
t[(x+1)%n][0]+=oddaje/2;
if(oddaje%2==0)
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] && 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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |