이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;cin>>n;
int a[n],b[n],c[n];
for(int i=0;i<n;i++) cin>>a[i]>>b[i];
for(int i=0;i<n;i++) c[i]=a[i]-b[i];
int i=0,cnt=0;
while(cnt!=n+1)
{
if(c[i]<=1) cnt++;
else c[(i+1)%n]+=(c[i]/2),c[i]%=2,cnt=0;
if(c[i]==1 && b[i]!=0)c[i]-=2,c[(i+1)%n]+=1,cnt=0;
i=(i+1)%n;
}
bool ok=1;
for(i=0;i<n;i++) if(c[i]!=0) ok=0;
cout<<(ok?"Yes":"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... |