#include<bits/stdc++.h>
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std ;
using ll = long long ;
using ld = long double ;
const int N = 1e6 + 7 , mod = 1e9 + 7 ;
const ll inf = 2e18 ;
// How interesting!
int n ;
vector<int> a(N , 0) , b(N , 0) ;
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in" , "r" , stdin) ;
cin >> n;
for(int i = 0 ; i < n ; ++ i){
cin >> a[i] >> b[i] ;
}
for(int k = 0 ; k < 100 ; ++ k){
for(int i = 0 ;i < n ; ++ i){
if(a[i] > b[i] && a[i] > 1){
int c = (a[i] - b[i] + 1) >> 1 ;
if(c * 2 > a[i]) c-- ;
a[i] -= c * 2 ;
a[(i+1)%n]+=c ;
}
}
if(a == b)
return cout<<"Yes" , 0 ;
}
cout<<"No" ;
return 0 ;
}
/*
- bounds sir (segtree = 4N, eulerTour = 2N, ...)
- a variable defined twice?
- will overflow?
- is it a good complexity?
- don't mess up indices (0-indexed vs 1-indexed)
- reset everything between testcases.
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
8192 KB |
Output is correct |
2 |
Correct |
6 ms |
8192 KB |
Output is correct |
3 |
Correct |
6 ms |
8192 KB |
Output is correct |
4 |
Correct |
7 ms |
8192 KB |
Output is correct |
5 |
Correct |
6 ms |
8192 KB |
Output is correct |
6 |
Correct |
6 ms |
8192 KB |
Output is correct |
7 |
Correct |
6 ms |
8192 KB |
Output is correct |
8 |
Correct |
6 ms |
8192 KB |
Output is correct |
9 |
Correct |
6 ms |
8192 KB |
Output is correct |
10 |
Correct |
6 ms |
8192 KB |
Output is correct |
11 |
Correct |
6 ms |
8192 KB |
Output is correct |
12 |
Correct |
6 ms |
8192 KB |
Output is correct |
13 |
Correct |
6 ms |
8192 KB |
Output is correct |
14 |
Correct |
6 ms |
8192 KB |
Output is correct |
15 |
Correct |
6 ms |
8192 KB |
Output is correct |
16 |
Correct |
6 ms |
8192 KB |
Output is correct |
17 |
Correct |
6 ms |
8192 KB |
Output is correct |
18 |
Correct |
6 ms |
8192 KB |
Output is correct |
19 |
Correct |
6 ms |
8192 KB |
Output is correct |
20 |
Correct |
8 ms |
8192 KB |
Output is correct |
21 |
Correct |
6 ms |
8192 KB |
Output is correct |
22 |
Correct |
6 ms |
8192 KB |
Output is correct |
23 |
Correct |
6 ms |
8192 KB |
Output is correct |
24 |
Correct |
6 ms |
8192 KB |
Output is correct |
25 |
Correct |
6 ms |
8192 KB |
Output is correct |
26 |
Correct |
6 ms |
8192 KB |
Output is correct |
27 |
Correct |
6 ms |
8192 KB |
Output is correct |
28 |
Correct |
6 ms |
8192 KB |
Output is correct |
29 |
Correct |
6 ms |
8192 KB |
Output is correct |
30 |
Correct |
6 ms |
8192 KB |
Output is correct |
31 |
Correct |
6 ms |
8192 KB |
Output is correct |
32 |
Correct |
7 ms |
8320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
8192 KB |
Output is correct |
2 |
Correct |
6 ms |
8192 KB |
Output is correct |
3 |
Correct |
6 ms |
8192 KB |
Output is correct |
4 |
Correct |
7 ms |
8192 KB |
Output is correct |
5 |
Correct |
6 ms |
8192 KB |
Output is correct |
6 |
Correct |
6 ms |
8192 KB |
Output is correct |
7 |
Correct |
6 ms |
8192 KB |
Output is correct |
8 |
Correct |
6 ms |
8192 KB |
Output is correct |
9 |
Correct |
6 ms |
8192 KB |
Output is correct |
10 |
Correct |
6 ms |
8192 KB |
Output is correct |
11 |
Correct |
6 ms |
8192 KB |
Output is correct |
12 |
Correct |
6 ms |
8192 KB |
Output is correct |
13 |
Correct |
6 ms |
8192 KB |
Output is correct |
14 |
Correct |
6 ms |
8192 KB |
Output is correct |
15 |
Correct |
6 ms |
8192 KB |
Output is correct |
16 |
Correct |
6 ms |
8192 KB |
Output is correct |
17 |
Correct |
6 ms |
8192 KB |
Output is correct |
18 |
Correct |
6 ms |
8192 KB |
Output is correct |
19 |
Correct |
6 ms |
8192 KB |
Output is correct |
20 |
Correct |
8 ms |
8192 KB |
Output is correct |
21 |
Correct |
6 ms |
8192 KB |
Output is correct |
22 |
Correct |
6 ms |
8192 KB |
Output is correct |
23 |
Correct |
6 ms |
8192 KB |
Output is correct |
24 |
Correct |
6 ms |
8192 KB |
Output is correct |
25 |
Correct |
6 ms |
8192 KB |
Output is correct |
26 |
Correct |
6 ms |
8192 KB |
Output is correct |
27 |
Correct |
6 ms |
8192 KB |
Output is correct |
28 |
Correct |
6 ms |
8192 KB |
Output is correct |
29 |
Correct |
6 ms |
8192 KB |
Output is correct |
30 |
Correct |
6 ms |
8192 KB |
Output is correct |
31 |
Correct |
6 ms |
8192 KB |
Output is correct |
32 |
Correct |
7 ms |
8320 KB |
Output is correct |
33 |
Correct |
6 ms |
8192 KB |
Output is correct |
34 |
Correct |
7 ms |
8192 KB |
Output is correct |
35 |
Correct |
6 ms |
8192 KB |
Output is correct |
36 |
Correct |
7 ms |
8192 KB |
Output is correct |
37 |
Correct |
6 ms |
8192 KB |
Output is correct |
38 |
Correct |
6 ms |
8192 KB |
Output is correct |
39 |
Correct |
7 ms |
8192 KB |
Output is correct |
40 |
Correct |
6 ms |
8192 KB |
Output is correct |
41 |
Correct |
7 ms |
8192 KB |
Output is correct |
42 |
Correct |
7 ms |
8320 KB |
Output is correct |
43 |
Correct |
6 ms |
8192 KB |
Output is correct |
44 |
Correct |
6 ms |
8192 KB |
Output is correct |
45 |
Correct |
6 ms |
8192 KB |
Output is correct |
46 |
Correct |
6 ms |
8192 KB |
Output is correct |
47 |
Correct |
6 ms |
8192 KB |
Output is correct |
48 |
Correct |
6 ms |
8192 KB |
Output is correct |
49 |
Correct |
6 ms |
8192 KB |
Output is correct |
50 |
Correct |
6 ms |
8192 KB |
Output is correct |
51 |
Correct |
6 ms |
8192 KB |
Output is correct |
52 |
Correct |
6 ms |
8192 KB |
Output is correct |
53 |
Correct |
6 ms |
8192 KB |
Output is correct |
54 |
Correct |
6 ms |
8192 KB |
Output is correct |
55 |
Correct |
6 ms |
8192 KB |
Output is correct |
56 |
Correct |
6 ms |
8192 KB |
Output is correct |
57 |
Correct |
6 ms |
8192 KB |
Output is correct |
58 |
Correct |
6 ms |
8192 KB |
Output is correct |
59 |
Correct |
6 ms |
8192 KB |
Output is correct |
60 |
Correct |
6 ms |
8192 KB |
Output is correct |
61 |
Correct |
7 ms |
8320 KB |
Output is correct |
62 |
Correct |
6 ms |
8192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
8192 KB |
Output is correct |
2 |
Correct |
6 ms |
8192 KB |
Output is correct |
3 |
Correct |
6 ms |
8192 KB |
Output is correct |
4 |
Correct |
7 ms |
8192 KB |
Output is correct |
5 |
Correct |
6 ms |
8192 KB |
Output is correct |
6 |
Correct |
6 ms |
8192 KB |
Output is correct |
7 |
Correct |
6 ms |
8192 KB |
Output is correct |
8 |
Correct |
6 ms |
8192 KB |
Output is correct |
9 |
Correct |
6 ms |
8192 KB |
Output is correct |
10 |
Correct |
6 ms |
8192 KB |
Output is correct |
11 |
Correct |
6 ms |
8192 KB |
Output is correct |
12 |
Correct |
6 ms |
8192 KB |
Output is correct |
13 |
Correct |
6 ms |
8192 KB |
Output is correct |
14 |
Correct |
6 ms |
8192 KB |
Output is correct |
15 |
Correct |
6 ms |
8192 KB |
Output is correct |
16 |
Correct |
6 ms |
8192 KB |
Output is correct |
17 |
Correct |
6 ms |
8192 KB |
Output is correct |
18 |
Correct |
6 ms |
8192 KB |
Output is correct |
19 |
Correct |
6 ms |
8192 KB |
Output is correct |
20 |
Correct |
8 ms |
8192 KB |
Output is correct |
21 |
Correct |
6 ms |
8192 KB |
Output is correct |
22 |
Correct |
6 ms |
8192 KB |
Output is correct |
23 |
Correct |
6 ms |
8192 KB |
Output is correct |
24 |
Correct |
6 ms |
8192 KB |
Output is correct |
25 |
Correct |
6 ms |
8192 KB |
Output is correct |
26 |
Correct |
6 ms |
8192 KB |
Output is correct |
27 |
Correct |
6 ms |
8192 KB |
Output is correct |
28 |
Correct |
6 ms |
8192 KB |
Output is correct |
29 |
Correct |
6 ms |
8192 KB |
Output is correct |
30 |
Correct |
6 ms |
8192 KB |
Output is correct |
31 |
Correct |
6 ms |
8192 KB |
Output is correct |
32 |
Correct |
7 ms |
8320 KB |
Output is correct |
33 |
Correct |
6 ms |
8192 KB |
Output is correct |
34 |
Correct |
7 ms |
8192 KB |
Output is correct |
35 |
Correct |
6 ms |
8192 KB |
Output is correct |
36 |
Correct |
7 ms |
8192 KB |
Output is correct |
37 |
Correct |
6 ms |
8192 KB |
Output is correct |
38 |
Correct |
6 ms |
8192 KB |
Output is correct |
39 |
Correct |
7 ms |
8192 KB |
Output is correct |
40 |
Correct |
6 ms |
8192 KB |
Output is correct |
41 |
Correct |
7 ms |
8192 KB |
Output is correct |
42 |
Correct |
7 ms |
8320 KB |
Output is correct |
43 |
Correct |
6 ms |
8192 KB |
Output is correct |
44 |
Correct |
6 ms |
8192 KB |
Output is correct |
45 |
Correct |
6 ms |
8192 KB |
Output is correct |
46 |
Correct |
6 ms |
8192 KB |
Output is correct |
47 |
Correct |
6 ms |
8192 KB |
Output is correct |
48 |
Correct |
6 ms |
8192 KB |
Output is correct |
49 |
Correct |
6 ms |
8192 KB |
Output is correct |
50 |
Correct |
6 ms |
8192 KB |
Output is correct |
51 |
Correct |
6 ms |
8192 KB |
Output is correct |
52 |
Correct |
6 ms |
8192 KB |
Output is correct |
53 |
Correct |
6 ms |
8192 KB |
Output is correct |
54 |
Correct |
6 ms |
8192 KB |
Output is correct |
55 |
Correct |
6 ms |
8192 KB |
Output is correct |
56 |
Correct |
6 ms |
8192 KB |
Output is correct |
57 |
Correct |
6 ms |
8192 KB |
Output is correct |
58 |
Correct |
6 ms |
8192 KB |
Output is correct |
59 |
Correct |
6 ms |
8192 KB |
Output is correct |
60 |
Correct |
6 ms |
8192 KB |
Output is correct |
61 |
Correct |
7 ms |
8320 KB |
Output is correct |
62 |
Correct |
6 ms |
8192 KB |
Output is correct |
63 |
Correct |
780 ms |
27512 KB |
Output is correct |
64 |
Correct |
150 ms |
12024 KB |
Output is correct |
65 |
Correct |
257 ms |
27128 KB |
Output is correct |
66 |
Correct |
152 ms |
12028 KB |
Output is correct |
67 |
Correct |
169 ms |
13436 KB |
Output is correct |
68 |
Correct |
182 ms |
15864 KB |
Output is correct |
69 |
Correct |
260 ms |
27640 KB |
Output is correct |
70 |
Correct |
706 ms |
12280 KB |
Output is correct |
71 |
Correct |
690 ms |
13560 KB |
Output is correct |
72 |
Correct |
726 ms |
15960 KB |
Output is correct |
73 |
Correct |
805 ms |
27812 KB |
Output is correct |
74 |
Correct |
693 ms |
12156 KB |
Output is correct |
75 |
Correct |
693 ms |
13608 KB |
Output is correct |
76 |
Correct |
704 ms |
16124 KB |
Output is correct |
77 |
Correct |
777 ms |
27640 KB |
Output is correct |
78 |
Correct |
736 ms |
19864 KB |
Output is correct |
79 |
Correct |
736 ms |
19960 KB |
Output is correct |
80 |
Correct |
203 ms |
19836 KB |
Output is correct |
81 |
Correct |
739 ms |
19752 KB |
Output is correct |
82 |
Correct |
656 ms |
12156 KB |
Output is correct |
83 |
Correct |
655 ms |
12152 KB |
Output is correct |
84 |
Correct |
137 ms |
12068 KB |
Output is correct |
85 |
Correct |
280 ms |
28592 KB |
Output is correct |
86 |
Correct |
856 ms |
28792 KB |
Output is correct |
87 |
Correct |
756 ms |
20984 KB |
Output is correct |
88 |
Correct |
243 ms |
21028 KB |
Output is correct |