#include <bits/stdc++.h>
using namespace std;
int main() {
int n; cin >> n;
vector<int> a(n), b(n);
for(int i = 0; i < n; ++i)cin >> a[i] >> b[i];
for(int j = 0; j < 40; ++j){
for(int i = 0; i < n; ++i){
if(a[i] <= 1)continue;
if(a[i] > b[i]){
a[(i+1)%n]+=(a[i]-b[i]+1)>>1;
a[i]-=(((a[i]-b[i]+1)>>1)<<1);
if(a[i] < 0){a[(i+1)%n]--;a[i]+=2;}
}
if(a == b){cout << "Yes\n";return 0;}
}
}
cout << "No\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |