#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=(1LL<<40);
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<ll> a(n),b(n);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
bool f=true;
while(1){
for(int i=0;i<n;i++){
if(a[i]<b[i]){
f=false;
break;
}
ll c=(a[i]-b[i]+1LL)/2LL;
a[i]-=2LL*c;
a[(i+1)%n]+=c;
}
if(!f){
break;
}
bool f2=true;
for(int i=0;i<n;i++){
if(a[i]!=b[i]){
f2=false;
}
}
if(f2){
break;
}
}
if(f){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Incorrect |
6 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |