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