// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using vl = V<ll>;
const int MX = 8e7;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
vl A(N), B(N); for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
for(int t = 0; t < MX / N; t++) {
for(int x = 0; x < N; x++) if (A[x] > B[x]) {
ll amt = min(A[x] / 2, (A[x] - B[x] + 1) / 2);
A[x] -= 2 * amt;
A[(x + 1) % N] += amt;
}
}
cout << (A == B ? "Yes" : "No") << nl;
exit(0-0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
348 KB |
Output is correct |
2 |
Correct |
53 ms |
348 KB |
Output is correct |
3 |
Correct |
55 ms |
500 KB |
Output is correct |
4 |
Correct |
55 ms |
428 KB |
Output is correct |
5 |
Correct |
61 ms |
596 KB |
Output is correct |
6 |
Correct |
58 ms |
348 KB |
Output is correct |
7 |
Correct |
57 ms |
348 KB |
Output is correct |
8 |
Correct |
52 ms |
432 KB |
Output is correct |
9 |
Correct |
54 ms |
432 KB |
Output is correct |
10 |
Correct |
78 ms |
344 KB |
Output is correct |
11 |
Correct |
75 ms |
348 KB |
Output is correct |
12 |
Correct |
54 ms |
344 KB |
Output is correct |
13 |
Correct |
53 ms |
348 KB |
Output is correct |
14 |
Correct |
92 ms |
428 KB |
Output is correct |
15 |
Correct |
61 ms |
348 KB |
Output is correct |
16 |
Correct |
207 ms |
432 KB |
Output is correct |
17 |
Correct |
109 ms |
544 KB |
Output is correct |
18 |
Correct |
82 ms |
436 KB |
Output is correct |
19 |
Correct |
87 ms |
344 KB |
Output is correct |
20 |
Correct |
366 ms |
504 KB |
Output is correct |
21 |
Correct |
365 ms |
432 KB |
Output is correct |
22 |
Correct |
79 ms |
348 KB |
Output is correct |
23 |
Correct |
319 ms |
432 KB |
Output is correct |
24 |
Correct |
57 ms |
348 KB |
Output is correct |
25 |
Correct |
58 ms |
344 KB |
Output is correct |
26 |
Correct |
367 ms |
432 KB |
Output is correct |
27 |
Correct |
63 ms |
432 KB |
Output is correct |
28 |
Correct |
57 ms |
512 KB |
Output is correct |
29 |
Correct |
58 ms |
348 KB |
Output is correct |
30 |
Correct |
57 ms |
344 KB |
Output is correct |
31 |
Correct |
364 ms |
432 KB |
Output is correct |
32 |
Correct |
58 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
348 KB |
Output is correct |
2 |
Correct |
53 ms |
348 KB |
Output is correct |
3 |
Correct |
55 ms |
500 KB |
Output is correct |
4 |
Correct |
55 ms |
428 KB |
Output is correct |
5 |
Correct |
61 ms |
596 KB |
Output is correct |
6 |
Correct |
58 ms |
348 KB |
Output is correct |
7 |
Correct |
57 ms |
348 KB |
Output is correct |
8 |
Correct |
52 ms |
432 KB |
Output is correct |
9 |
Correct |
54 ms |
432 KB |
Output is correct |
10 |
Correct |
78 ms |
344 KB |
Output is correct |
11 |
Correct |
75 ms |
348 KB |
Output is correct |
12 |
Correct |
54 ms |
344 KB |
Output is correct |
13 |
Correct |
53 ms |
348 KB |
Output is correct |
14 |
Correct |
92 ms |
428 KB |
Output is correct |
15 |
Correct |
61 ms |
348 KB |
Output is correct |
16 |
Correct |
207 ms |
432 KB |
Output is correct |
17 |
Correct |
109 ms |
544 KB |
Output is correct |
18 |
Correct |
82 ms |
436 KB |
Output is correct |
19 |
Correct |
87 ms |
344 KB |
Output is correct |
20 |
Correct |
366 ms |
504 KB |
Output is correct |
21 |
Correct |
365 ms |
432 KB |
Output is correct |
22 |
Correct |
79 ms |
348 KB |
Output is correct |
23 |
Correct |
319 ms |
432 KB |
Output is correct |
24 |
Correct |
57 ms |
348 KB |
Output is correct |
25 |
Correct |
58 ms |
344 KB |
Output is correct |
26 |
Correct |
367 ms |
432 KB |
Output is correct |
27 |
Correct |
63 ms |
432 KB |
Output is correct |
28 |
Correct |
57 ms |
512 KB |
Output is correct |
29 |
Correct |
58 ms |
348 KB |
Output is correct |
30 |
Correct |
57 ms |
344 KB |
Output is correct |
31 |
Correct |
364 ms |
432 KB |
Output is correct |
32 |
Correct |
58 ms |
348 KB |
Output is correct |
33 |
Correct |
60 ms |
428 KB |
Output is correct |
34 |
Correct |
54 ms |
344 KB |
Output is correct |
35 |
Correct |
56 ms |
428 KB |
Output is correct |
36 |
Correct |
56 ms |
428 KB |
Output is correct |
37 |
Correct |
54 ms |
428 KB |
Output is correct |
38 |
Correct |
52 ms |
348 KB |
Output is correct |
39 |
Correct |
66 ms |
432 KB |
Output is correct |
40 |
Correct |
55 ms |
348 KB |
Output is correct |
41 |
Correct |
54 ms |
428 KB |
Output is correct |
42 |
Correct |
55 ms |
348 KB |
Output is correct |
43 |
Correct |
62 ms |
432 KB |
Output is correct |
44 |
Correct |
54 ms |
344 KB |
Output is correct |
45 |
Correct |
59 ms |
432 KB |
Output is correct |
46 |
Correct |
52 ms |
504 KB |
Output is correct |
47 |
Correct |
60 ms |
344 KB |
Output is correct |
48 |
Correct |
65 ms |
428 KB |
Output is correct |
49 |
Correct |
56 ms |
348 KB |
Output is correct |
50 |
Correct |
378 ms |
436 KB |
Output is correct |
51 |
Correct |
365 ms |
348 KB |
Output is correct |
52 |
Correct |
209 ms |
348 KB |
Output is correct |
53 |
Correct |
344 ms |
600 KB |
Output is correct |
54 |
Correct |
54 ms |
348 KB |
Output is correct |
55 |
Correct |
55 ms |
348 KB |
Output is correct |
56 |
Correct |
364 ms |
344 KB |
Output is correct |
57 |
Correct |
55 ms |
348 KB |
Output is correct |
58 |
Correct |
55 ms |
348 KB |
Output is correct |
59 |
Correct |
54 ms |
344 KB |
Output is correct |
60 |
Correct |
58 ms |
348 KB |
Output is correct |
61 |
Correct |
364 ms |
344 KB |
Output is correct |
62 |
Correct |
55 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
348 KB |
Output is correct |
2 |
Correct |
53 ms |
348 KB |
Output is correct |
3 |
Correct |
55 ms |
500 KB |
Output is correct |
4 |
Correct |
55 ms |
428 KB |
Output is correct |
5 |
Correct |
61 ms |
596 KB |
Output is correct |
6 |
Correct |
58 ms |
348 KB |
Output is correct |
7 |
Correct |
57 ms |
348 KB |
Output is correct |
8 |
Correct |
52 ms |
432 KB |
Output is correct |
9 |
Correct |
54 ms |
432 KB |
Output is correct |
10 |
Correct |
78 ms |
344 KB |
Output is correct |
11 |
Correct |
75 ms |
348 KB |
Output is correct |
12 |
Correct |
54 ms |
344 KB |
Output is correct |
13 |
Correct |
53 ms |
348 KB |
Output is correct |
14 |
Correct |
92 ms |
428 KB |
Output is correct |
15 |
Correct |
61 ms |
348 KB |
Output is correct |
16 |
Correct |
207 ms |
432 KB |
Output is correct |
17 |
Correct |
109 ms |
544 KB |
Output is correct |
18 |
Correct |
82 ms |
436 KB |
Output is correct |
19 |
Correct |
87 ms |
344 KB |
Output is correct |
20 |
Correct |
366 ms |
504 KB |
Output is correct |
21 |
Correct |
365 ms |
432 KB |
Output is correct |
22 |
Correct |
79 ms |
348 KB |
Output is correct |
23 |
Correct |
319 ms |
432 KB |
Output is correct |
24 |
Correct |
57 ms |
348 KB |
Output is correct |
25 |
Correct |
58 ms |
344 KB |
Output is correct |
26 |
Correct |
367 ms |
432 KB |
Output is correct |
27 |
Correct |
63 ms |
432 KB |
Output is correct |
28 |
Correct |
57 ms |
512 KB |
Output is correct |
29 |
Correct |
58 ms |
348 KB |
Output is correct |
30 |
Correct |
57 ms |
344 KB |
Output is correct |
31 |
Correct |
364 ms |
432 KB |
Output is correct |
32 |
Correct |
58 ms |
348 KB |
Output is correct |
33 |
Correct |
60 ms |
428 KB |
Output is correct |
34 |
Correct |
54 ms |
344 KB |
Output is correct |
35 |
Correct |
56 ms |
428 KB |
Output is correct |
36 |
Correct |
56 ms |
428 KB |
Output is correct |
37 |
Correct |
54 ms |
428 KB |
Output is correct |
38 |
Correct |
52 ms |
348 KB |
Output is correct |
39 |
Correct |
66 ms |
432 KB |
Output is correct |
40 |
Correct |
55 ms |
348 KB |
Output is correct |
41 |
Correct |
54 ms |
428 KB |
Output is correct |
42 |
Correct |
55 ms |
348 KB |
Output is correct |
43 |
Correct |
62 ms |
432 KB |
Output is correct |
44 |
Correct |
54 ms |
344 KB |
Output is correct |
45 |
Correct |
59 ms |
432 KB |
Output is correct |
46 |
Correct |
52 ms |
504 KB |
Output is correct |
47 |
Correct |
60 ms |
344 KB |
Output is correct |
48 |
Correct |
65 ms |
428 KB |
Output is correct |
49 |
Correct |
56 ms |
348 KB |
Output is correct |
50 |
Correct |
378 ms |
436 KB |
Output is correct |
51 |
Correct |
365 ms |
348 KB |
Output is correct |
52 |
Correct |
209 ms |
348 KB |
Output is correct |
53 |
Correct |
344 ms |
600 KB |
Output is correct |
54 |
Correct |
54 ms |
348 KB |
Output is correct |
55 |
Correct |
55 ms |
348 KB |
Output is correct |
56 |
Correct |
364 ms |
344 KB |
Output is correct |
57 |
Correct |
55 ms |
348 KB |
Output is correct |
58 |
Correct |
55 ms |
348 KB |
Output is correct |
59 |
Correct |
54 ms |
344 KB |
Output is correct |
60 |
Correct |
58 ms |
348 KB |
Output is correct |
61 |
Correct |
364 ms |
344 KB |
Output is correct |
62 |
Correct |
55 ms |
344 KB |
Output is correct |
63 |
Correct |
245 ms |
35408 KB |
Output is correct |
64 |
Correct |
147 ms |
19796 KB |
Output is correct |
65 |
Correct |
220 ms |
35156 KB |
Output is correct |
66 |
Correct |
144 ms |
19796 KB |
Output is correct |
67 |
Correct |
147 ms |
21228 KB |
Output is correct |
68 |
Correct |
193 ms |
23764 KB |
Output is correct |
69 |
Correct |
219 ms |
35408 KB |
Output is correct |
70 |
Correct |
145 ms |
20024 KB |
Output is correct |
71 |
Correct |
160 ms |
21412 KB |
Output is correct |
72 |
Correct |
158 ms |
23636 KB |
Output is correct |
73 |
Correct |
214 ms |
35308 KB |
Output is correct |
74 |
Correct |
152 ms |
20024 KB |
Output is correct |
75 |
Correct |
151 ms |
21332 KB |
Output is correct |
76 |
Correct |
177 ms |
23784 KB |
Output is correct |
77 |
Correct |
217 ms |
35668 KB |
Output is correct |
78 |
Correct |
480 ms |
27740 KB |
Output is correct |
79 |
Correct |
488 ms |
27744 KB |
Output is correct |
80 |
Correct |
175 ms |
27740 KB |
Output is correct |
81 |
Correct |
189 ms |
27732 KB |
Output is correct |
82 |
Correct |
440 ms |
19792 KB |
Output is correct |
83 |
Correct |
156 ms |
19796 KB |
Output is correct |
84 |
Correct |
133 ms |
20024 KB |
Output is correct |
85 |
Correct |
217 ms |
36480 KB |
Output is correct |
86 |
Correct |
213 ms |
36432 KB |
Output is correct |
87 |
Correct |
479 ms |
28764 KB |
Output is correct |
88 |
Correct |
211 ms |
28756 KB |
Output is correct |