#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
#define int ll
using namespace std;
const int N = 1e6+5;
int n, x, b[N][2];
bool solve(int k)
{
for (int i=0;i<N*2;++i)
{
x=b[(k+i)%n][0]-b[(k+i)%n][1];
if (x>0)
{
b[(k+i)%n][0]-=((x+(b[(k+i)%n][1]!=0))/2)*2;
b[(k+i+1)%n][0]+=(x+(b[(k+i)%n][1]!=0))/2;
}
}
for (int i=0;i<n;++i)
if (b[i][0]!=b[i][1])
return 0;
return 1;
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for (int i=0;i<n;++i)
cin>>b[i][0]>>b[i][1];
if (solve(0))
cout<<"Yes";
else
cout<<"No";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
204 KB |
Output is correct |
2 |
Correct |
18 ms |
316 KB |
Output is correct |
3 |
Correct |
18 ms |
312 KB |
Output is correct |
4 |
Correct |
18 ms |
204 KB |
Output is correct |
5 |
Correct |
18 ms |
312 KB |
Output is correct |
6 |
Correct |
18 ms |
204 KB |
Output is correct |
7 |
Correct |
18 ms |
320 KB |
Output is correct |
8 |
Correct |
18 ms |
312 KB |
Output is correct |
9 |
Correct |
17 ms |
204 KB |
Output is correct |
10 |
Correct |
18 ms |
320 KB |
Output is correct |
11 |
Correct |
17 ms |
312 KB |
Output is correct |
12 |
Correct |
18 ms |
320 KB |
Output is correct |
13 |
Correct |
17 ms |
204 KB |
Output is correct |
14 |
Correct |
18 ms |
320 KB |
Output is correct |
15 |
Correct |
17 ms |
204 KB |
Output is correct |
16 |
Correct |
27 ms |
320 KB |
Output is correct |
17 |
Correct |
22 ms |
312 KB |
Output is correct |
18 |
Correct |
18 ms |
204 KB |
Output is correct |
19 |
Correct |
20 ms |
312 KB |
Output is correct |
20 |
Correct |
36 ms |
204 KB |
Output is correct |
21 |
Correct |
34 ms |
204 KB |
Output is correct |
22 |
Correct |
20 ms |
316 KB |
Output is correct |
23 |
Correct |
32 ms |
296 KB |
Output is correct |
24 |
Correct |
18 ms |
316 KB |
Output is correct |
25 |
Correct |
18 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
204 KB |
Output is correct |
27 |
Correct |
17 ms |
312 KB |
Output is correct |
28 |
Correct |
17 ms |
204 KB |
Output is correct |
29 |
Correct |
18 ms |
316 KB |
Output is correct |
30 |
Correct |
18 ms |
204 KB |
Output is correct |
31 |
Correct |
35 ms |
204 KB |
Output is correct |
32 |
Correct |
17 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
204 KB |
Output is correct |
2 |
Correct |
18 ms |
316 KB |
Output is correct |
3 |
Correct |
18 ms |
312 KB |
Output is correct |
4 |
Correct |
18 ms |
204 KB |
Output is correct |
5 |
Correct |
18 ms |
312 KB |
Output is correct |
6 |
Correct |
18 ms |
204 KB |
Output is correct |
7 |
Correct |
18 ms |
320 KB |
Output is correct |
8 |
Correct |
18 ms |
312 KB |
Output is correct |
9 |
Correct |
17 ms |
204 KB |
Output is correct |
10 |
Correct |
18 ms |
320 KB |
Output is correct |
11 |
Correct |
17 ms |
312 KB |
Output is correct |
12 |
Correct |
18 ms |
320 KB |
Output is correct |
13 |
Correct |
17 ms |
204 KB |
Output is correct |
14 |
Correct |
18 ms |
320 KB |
Output is correct |
15 |
Correct |
17 ms |
204 KB |
Output is correct |
16 |
Correct |
27 ms |
320 KB |
Output is correct |
17 |
Correct |
22 ms |
312 KB |
Output is correct |
18 |
Correct |
18 ms |
204 KB |
Output is correct |
19 |
Correct |
20 ms |
312 KB |
Output is correct |
20 |
Correct |
36 ms |
204 KB |
Output is correct |
21 |
Correct |
34 ms |
204 KB |
Output is correct |
22 |
Correct |
20 ms |
316 KB |
Output is correct |
23 |
Correct |
32 ms |
296 KB |
Output is correct |
24 |
Correct |
18 ms |
316 KB |
Output is correct |
25 |
Correct |
18 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
204 KB |
Output is correct |
27 |
Correct |
17 ms |
312 KB |
Output is correct |
28 |
Correct |
17 ms |
204 KB |
Output is correct |
29 |
Correct |
18 ms |
316 KB |
Output is correct |
30 |
Correct |
18 ms |
204 KB |
Output is correct |
31 |
Correct |
35 ms |
204 KB |
Output is correct |
32 |
Correct |
17 ms |
204 KB |
Output is correct |
33 |
Correct |
18 ms |
312 KB |
Output is correct |
34 |
Correct |
17 ms |
204 KB |
Output is correct |
35 |
Correct |
18 ms |
204 KB |
Output is correct |
36 |
Correct |
18 ms |
316 KB |
Output is correct |
37 |
Correct |
17 ms |
204 KB |
Output is correct |
38 |
Correct |
18 ms |
320 KB |
Output is correct |
39 |
Correct |
18 ms |
204 KB |
Output is correct |
40 |
Correct |
17 ms |
320 KB |
Output is correct |
41 |
Correct |
17 ms |
320 KB |
Output is correct |
42 |
Correct |
19 ms |
204 KB |
Output is correct |
43 |
Correct |
18 ms |
316 KB |
Output is correct |
44 |
Correct |
17 ms |
312 KB |
Output is correct |
45 |
Correct |
19 ms |
312 KB |
Output is correct |
46 |
Correct |
18 ms |
316 KB |
Output is correct |
47 |
Correct |
18 ms |
204 KB |
Output is correct |
48 |
Correct |
17 ms |
316 KB |
Output is correct |
49 |
Correct |
17 ms |
204 KB |
Output is correct |
50 |
Correct |
35 ms |
300 KB |
Output is correct |
51 |
Correct |
33 ms |
204 KB |
Output is correct |
52 |
Correct |
26 ms |
204 KB |
Output is correct |
53 |
Correct |
33 ms |
204 KB |
Output is correct |
54 |
Correct |
17 ms |
312 KB |
Output is correct |
55 |
Correct |
17 ms |
204 KB |
Output is correct |
56 |
Correct |
33 ms |
204 KB |
Output is correct |
57 |
Correct |
17 ms |
320 KB |
Output is correct |
58 |
Correct |
16 ms |
316 KB |
Output is correct |
59 |
Correct |
17 ms |
316 KB |
Output is correct |
60 |
Correct |
17 ms |
204 KB |
Output is correct |
61 |
Correct |
33 ms |
292 KB |
Output is correct |
62 |
Correct |
17 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
204 KB |
Output is correct |
2 |
Correct |
18 ms |
316 KB |
Output is correct |
3 |
Correct |
18 ms |
312 KB |
Output is correct |
4 |
Correct |
18 ms |
204 KB |
Output is correct |
5 |
Correct |
18 ms |
312 KB |
Output is correct |
6 |
Correct |
18 ms |
204 KB |
Output is correct |
7 |
Correct |
18 ms |
320 KB |
Output is correct |
8 |
Correct |
18 ms |
312 KB |
Output is correct |
9 |
Correct |
17 ms |
204 KB |
Output is correct |
10 |
Correct |
18 ms |
320 KB |
Output is correct |
11 |
Correct |
17 ms |
312 KB |
Output is correct |
12 |
Correct |
18 ms |
320 KB |
Output is correct |
13 |
Correct |
17 ms |
204 KB |
Output is correct |
14 |
Correct |
18 ms |
320 KB |
Output is correct |
15 |
Correct |
17 ms |
204 KB |
Output is correct |
16 |
Correct |
27 ms |
320 KB |
Output is correct |
17 |
Correct |
22 ms |
312 KB |
Output is correct |
18 |
Correct |
18 ms |
204 KB |
Output is correct |
19 |
Correct |
20 ms |
312 KB |
Output is correct |
20 |
Correct |
36 ms |
204 KB |
Output is correct |
21 |
Correct |
34 ms |
204 KB |
Output is correct |
22 |
Correct |
20 ms |
316 KB |
Output is correct |
23 |
Correct |
32 ms |
296 KB |
Output is correct |
24 |
Correct |
18 ms |
316 KB |
Output is correct |
25 |
Correct |
18 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
204 KB |
Output is correct |
27 |
Correct |
17 ms |
312 KB |
Output is correct |
28 |
Correct |
17 ms |
204 KB |
Output is correct |
29 |
Correct |
18 ms |
316 KB |
Output is correct |
30 |
Correct |
18 ms |
204 KB |
Output is correct |
31 |
Correct |
35 ms |
204 KB |
Output is correct |
32 |
Correct |
17 ms |
204 KB |
Output is correct |
33 |
Correct |
18 ms |
312 KB |
Output is correct |
34 |
Correct |
17 ms |
204 KB |
Output is correct |
35 |
Correct |
18 ms |
204 KB |
Output is correct |
36 |
Correct |
18 ms |
316 KB |
Output is correct |
37 |
Correct |
17 ms |
204 KB |
Output is correct |
38 |
Correct |
18 ms |
320 KB |
Output is correct |
39 |
Correct |
18 ms |
204 KB |
Output is correct |
40 |
Correct |
17 ms |
320 KB |
Output is correct |
41 |
Correct |
17 ms |
320 KB |
Output is correct |
42 |
Correct |
19 ms |
204 KB |
Output is correct |
43 |
Correct |
18 ms |
316 KB |
Output is correct |
44 |
Correct |
17 ms |
312 KB |
Output is correct |
45 |
Correct |
19 ms |
312 KB |
Output is correct |
46 |
Correct |
18 ms |
316 KB |
Output is correct |
47 |
Correct |
18 ms |
204 KB |
Output is correct |
48 |
Correct |
17 ms |
316 KB |
Output is correct |
49 |
Correct |
17 ms |
204 KB |
Output is correct |
50 |
Correct |
35 ms |
300 KB |
Output is correct |
51 |
Correct |
33 ms |
204 KB |
Output is correct |
52 |
Correct |
26 ms |
204 KB |
Output is correct |
53 |
Correct |
33 ms |
204 KB |
Output is correct |
54 |
Correct |
17 ms |
312 KB |
Output is correct |
55 |
Correct |
17 ms |
204 KB |
Output is correct |
56 |
Correct |
33 ms |
204 KB |
Output is correct |
57 |
Correct |
17 ms |
320 KB |
Output is correct |
58 |
Correct |
16 ms |
316 KB |
Output is correct |
59 |
Correct |
17 ms |
316 KB |
Output is correct |
60 |
Correct |
17 ms |
204 KB |
Output is correct |
61 |
Correct |
33 ms |
292 KB |
Output is correct |
62 |
Correct |
17 ms |
312 KB |
Output is correct |
63 |
Correct |
260 ms |
16016 KB |
Output is correct |
64 |
Correct |
173 ms |
15948 KB |
Output is correct |
65 |
Correct |
268 ms |
15936 KB |
Output is correct |
66 |
Correct |
170 ms |
15840 KB |
Output is correct |
67 |
Correct |
208 ms |
15940 KB |
Output is correct |
68 |
Correct |
191 ms |
16068 KB |
Output is correct |
69 |
Correct |
262 ms |
15828 KB |
Output is correct |
70 |
Correct |
169 ms |
15824 KB |
Output is correct |
71 |
Correct |
175 ms |
15852 KB |
Output is correct |
72 |
Correct |
186 ms |
15888 KB |
Output is correct |
73 |
Correct |
264 ms |
15928 KB |
Output is correct |
74 |
Correct |
170 ms |
15940 KB |
Output is correct |
75 |
Correct |
171 ms |
15904 KB |
Output is correct |
76 |
Correct |
187 ms |
15944 KB |
Output is correct |
77 |
Correct |
274 ms |
15868 KB |
Output is correct |
78 |
Correct |
224 ms |
15848 KB |
Output is correct |
79 |
Correct |
227 ms |
15928 KB |
Output is correct |
80 |
Correct |
220 ms |
15868 KB |
Output is correct |
81 |
Correct |
225 ms |
15904 KB |
Output is correct |
82 |
Correct |
175 ms |
15948 KB |
Output is correct |
83 |
Correct |
159 ms |
15860 KB |
Output is correct |
84 |
Correct |
152 ms |
15920 KB |
Output is correct |
85 |
Correct |
308 ms |
15888 KB |
Output is correct |
86 |
Correct |
282 ms |
15972 KB |
Output is correct |
87 |
Correct |
250 ms |
15996 KB |
Output is correct |
88 |
Correct |
240 ms |
15828 KB |
Output is correct |