#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e6 + 9;
int n, nxt[N];
ll a[N], b[N];
int main() {
cin.tie(NULL)->sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i] >> b[i], a[i] -= b[i], nxt[i] = i % n + 1;
for (int times = 0; times * n < 1e7; ++times)
for (int i = 1; i <= n; ++i)
if (a[i] > 0) {
ll tmp = a[i] >> 1;
a[i] -= tmp << 1;
a[nxt[i]] += tmp;
}
ll ma = *max_element(a + 1, a + n + 1);
ll mi = *min_element(a + 1, a + n + 1);
if (ma == mi && (ma == 1 || ma == 0))
cout << "Yes\n";
else cout << "No\n";
}
/** /\_/\
* (= ._.)
* / >0 \>1
**/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
212 KB |
Output is correct |
2 |
Correct |
11 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
340 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
8 ms |
340 KB |
Output is correct |
7 |
Correct |
8 ms |
340 KB |
Output is correct |
8 |
Correct |
31 ms |
324 KB |
Output is correct |
9 |
Correct |
9 ms |
340 KB |
Output is correct |
10 |
Correct |
9 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
324 KB |
Output is correct |
12 |
Correct |
17 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
340 KB |
Output is correct |
14 |
Correct |
14 ms |
340 KB |
Output is correct |
15 |
Correct |
11 ms |
320 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
10 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Incorrect |
31 ms |
324 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
212 KB |
Output is correct |
2 |
Correct |
11 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
340 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
8 ms |
340 KB |
Output is correct |
7 |
Correct |
8 ms |
340 KB |
Output is correct |
8 |
Correct |
31 ms |
324 KB |
Output is correct |
9 |
Correct |
9 ms |
340 KB |
Output is correct |
10 |
Correct |
9 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
324 KB |
Output is correct |
12 |
Correct |
17 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
340 KB |
Output is correct |
14 |
Correct |
14 ms |
340 KB |
Output is correct |
15 |
Correct |
11 ms |
320 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
10 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Incorrect |
31 ms |
324 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
212 KB |
Output is correct |
2 |
Correct |
11 ms |
348 KB |
Output is correct |
3 |
Correct |
12 ms |
212 KB |
Output is correct |
4 |
Correct |
10 ms |
340 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
8 ms |
340 KB |
Output is correct |
7 |
Correct |
8 ms |
340 KB |
Output is correct |
8 |
Correct |
31 ms |
324 KB |
Output is correct |
9 |
Correct |
9 ms |
340 KB |
Output is correct |
10 |
Correct |
9 ms |
344 KB |
Output is correct |
11 |
Correct |
9 ms |
324 KB |
Output is correct |
12 |
Correct |
17 ms |
344 KB |
Output is correct |
13 |
Correct |
9 ms |
340 KB |
Output is correct |
14 |
Correct |
14 ms |
340 KB |
Output is correct |
15 |
Correct |
11 ms |
320 KB |
Output is correct |
16 |
Correct |
18 ms |
340 KB |
Output is correct |
17 |
Correct |
10 ms |
212 KB |
Output is correct |
18 |
Correct |
10 ms |
340 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Incorrect |
31 ms |
324 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |