#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)
const int MN = 1000005;
int n;
pii a[MN * 2];
int32_t main() {
boost();
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].f >> a[i].s;
for (int i = 0; i < MN; i++) {
if (a[i].s > a[i].f) {
int d = a[i].s - a[i].f;
a[i].s -= d;
a[i + n].s += d;
}
int d = a[i].f - a[i].s;
int tk = (d + 1) / 2;
a[i].f -= tk * 2;
a[i + 1].f += tk;
if (a[i].s > a[i].f) {
int d = a[i].s - a[i].f;
a[i].s -= d;
a[i + n].s += d;
}
}
for (int i = 0; i < MN * 2; i++) {
assert(a[i].f >= 0 && a[i].s >= 0);
if (a[i].f != a[i].s) return 0 * printf("No\n");
}
printf("Yes\n");
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
15952 KB |
Output is correct |
2 |
Correct |
15 ms |
15956 KB |
Output is correct |
3 |
Correct |
14 ms |
15984 KB |
Output is correct |
4 |
Runtime error |
24 ms |
32164 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
15952 KB |
Output is correct |
2 |
Correct |
15 ms |
15956 KB |
Output is correct |
3 |
Correct |
14 ms |
15984 KB |
Output is correct |
4 |
Runtime error |
24 ms |
32164 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
15952 KB |
Output is correct |
2 |
Correct |
15 ms |
15956 KB |
Output is correct |
3 |
Correct |
14 ms |
15984 KB |
Output is correct |
4 |
Runtime error |
24 ms |
32164 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |