#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=3e5+7;
ll n,m,k;
vector<ll>a,b;
void change(ll i, ll tal){
i%=n;
for(ll j=0;j<1000*n;j+=n){
a[i+j]-=tal*2;
a[(i+1)%n+j]+=tal;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("output.txt","w",stdout);
cin>>n;
for(ll i=0;i<n;i++){
ll x,y;
cin>>x>>y;
a.push_back(x);
b.push_back(y);
}
for(ll i=0;i<999*n;i++){
a.push_back(a[i]);
b.push_back(b[i]);
}
for(ll i=0;i<1000*n;i++){
if(a[i]!=b[i]){
ll tal=0;
if(a[i]!=1&&a[i]>b[i]){
if(a[i]%2==b[i]%2){
tal=(a[i]-b[i])/2;
}
else{
tal=(a[i]-b[i]+1)/2;
if(b[i]==0){
tal--;
}
}
}
// cout<<i%n<<": "<<a[i]<<", "<<b[i]<<": "<<tal<<endl;
change(i,tal);
}
}
for(ll i=0;i<n;i++){
// cout<<a[i]<<" "<<b[i]<<endl;
if(a[i]!=b[i]){
cout<<"No"<<endl;
return 0;
}
}
cout<<"Yes"<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
520 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
0 ms |
468 KB |
Output is correct |
12 |
Correct |
5 ms |
372 KB |
Output is correct |
13 |
Correct |
5 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
5 ms |
468 KB |
Output is correct |
16 |
Correct |
9 ms |
376 KB |
Output is correct |
17 |
Correct |
9 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
468 KB |
Output is correct |
19 |
Correct |
14 ms |
528 KB |
Output is correct |
20 |
Correct |
47 ms |
504 KB |
Output is correct |
21 |
Correct |
31 ms |
468 KB |
Output is correct |
22 |
Correct |
5 ms |
468 KB |
Output is correct |
23 |
Correct |
26 ms |
524 KB |
Output is correct |
24 |
Correct |
0 ms |
468 KB |
Output is correct |
25 |
Correct |
26 ms |
468 KB |
Output is correct |
26 |
Correct |
30 ms |
468 KB |
Output is correct |
27 |
Correct |
30 ms |
524 KB |
Output is correct |
28 |
Correct |
0 ms |
468 KB |
Output is correct |
29 |
Correct |
0 ms |
468 KB |
Output is correct |
30 |
Correct |
26 ms |
468 KB |
Output is correct |
31 |
Correct |
31 ms |
468 KB |
Output is correct |
32 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
520 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
0 ms |
468 KB |
Output is correct |
12 |
Correct |
5 ms |
372 KB |
Output is correct |
13 |
Correct |
5 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
5 ms |
468 KB |
Output is correct |
16 |
Correct |
9 ms |
376 KB |
Output is correct |
17 |
Correct |
9 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
468 KB |
Output is correct |
19 |
Correct |
14 ms |
528 KB |
Output is correct |
20 |
Correct |
47 ms |
504 KB |
Output is correct |
21 |
Correct |
31 ms |
468 KB |
Output is correct |
22 |
Correct |
5 ms |
468 KB |
Output is correct |
23 |
Correct |
26 ms |
524 KB |
Output is correct |
24 |
Correct |
0 ms |
468 KB |
Output is correct |
25 |
Correct |
26 ms |
468 KB |
Output is correct |
26 |
Correct |
30 ms |
468 KB |
Output is correct |
27 |
Correct |
30 ms |
524 KB |
Output is correct |
28 |
Correct |
0 ms |
468 KB |
Output is correct |
29 |
Correct |
0 ms |
468 KB |
Output is correct |
30 |
Correct |
26 ms |
468 KB |
Output is correct |
31 |
Correct |
31 ms |
468 KB |
Output is correct |
32 |
Correct |
0 ms |
468 KB |
Output is correct |
33 |
Correct |
78 ms |
848 KB |
Output is correct |
34 |
Correct |
1 ms |
848 KB |
Output is correct |
35 |
Correct |
1 ms |
848 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
848 KB |
Output is correct |
38 |
Correct |
1 ms |
340 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
848 KB |
Output is correct |
41 |
Correct |
1 ms |
848 KB |
Output is correct |
42 |
Correct |
5 ms |
340 KB |
Output is correct |
43 |
Correct |
18 ms |
500 KB |
Output is correct |
44 |
Correct |
82 ms |
848 KB |
Output is correct |
45 |
Correct |
14 ms |
868 KB |
Output is correct |
46 |
Correct |
6 ms |
352 KB |
Output is correct |
47 |
Correct |
12 ms |
468 KB |
Output is correct |
48 |
Correct |
52 ms |
852 KB |
Output is correct |
49 |
Correct |
1 ms |
848 KB |
Output is correct |
50 |
Correct |
9 ms |
340 KB |
Output is correct |
51 |
Correct |
87 ms |
848 KB |
Output is correct |
52 |
Correct |
5 ms |
340 KB |
Output is correct |
53 |
Correct |
83 ms |
848 KB |
Output is correct |
54 |
Correct |
1 ms |
848 KB |
Output is correct |
55 |
Correct |
6 ms |
848 KB |
Output is correct |
56 |
Correct |
87 ms |
856 KB |
Output is correct |
57 |
Correct |
87 ms |
848 KB |
Output is correct |
58 |
Correct |
1 ms |
848 KB |
Output is correct |
59 |
Correct |
1 ms |
848 KB |
Output is correct |
60 |
Correct |
6 ms |
832 KB |
Output is correct |
61 |
Correct |
86 ms |
836 KB |
Output is correct |
62 |
Correct |
1 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
520 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
468 KB |
Output is correct |
7 |
Correct |
0 ms |
468 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
0 ms |
468 KB |
Output is correct |
12 |
Correct |
5 ms |
372 KB |
Output is correct |
13 |
Correct |
5 ms |
340 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
5 ms |
468 KB |
Output is correct |
16 |
Correct |
9 ms |
376 KB |
Output is correct |
17 |
Correct |
9 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
468 KB |
Output is correct |
19 |
Correct |
14 ms |
528 KB |
Output is correct |
20 |
Correct |
47 ms |
504 KB |
Output is correct |
21 |
Correct |
31 ms |
468 KB |
Output is correct |
22 |
Correct |
5 ms |
468 KB |
Output is correct |
23 |
Correct |
26 ms |
524 KB |
Output is correct |
24 |
Correct |
0 ms |
468 KB |
Output is correct |
25 |
Correct |
26 ms |
468 KB |
Output is correct |
26 |
Correct |
30 ms |
468 KB |
Output is correct |
27 |
Correct |
30 ms |
524 KB |
Output is correct |
28 |
Correct |
0 ms |
468 KB |
Output is correct |
29 |
Correct |
0 ms |
468 KB |
Output is correct |
30 |
Correct |
26 ms |
468 KB |
Output is correct |
31 |
Correct |
31 ms |
468 KB |
Output is correct |
32 |
Correct |
0 ms |
468 KB |
Output is correct |
33 |
Correct |
78 ms |
848 KB |
Output is correct |
34 |
Correct |
1 ms |
848 KB |
Output is correct |
35 |
Correct |
1 ms |
848 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
848 KB |
Output is correct |
38 |
Correct |
1 ms |
340 KB |
Output is correct |
39 |
Correct |
1 ms |
468 KB |
Output is correct |
40 |
Correct |
1 ms |
848 KB |
Output is correct |
41 |
Correct |
1 ms |
848 KB |
Output is correct |
42 |
Correct |
5 ms |
340 KB |
Output is correct |
43 |
Correct |
18 ms |
500 KB |
Output is correct |
44 |
Correct |
82 ms |
848 KB |
Output is correct |
45 |
Correct |
14 ms |
868 KB |
Output is correct |
46 |
Correct |
6 ms |
352 KB |
Output is correct |
47 |
Correct |
12 ms |
468 KB |
Output is correct |
48 |
Correct |
52 ms |
852 KB |
Output is correct |
49 |
Correct |
1 ms |
848 KB |
Output is correct |
50 |
Correct |
9 ms |
340 KB |
Output is correct |
51 |
Correct |
87 ms |
848 KB |
Output is correct |
52 |
Correct |
5 ms |
340 KB |
Output is correct |
53 |
Correct |
83 ms |
848 KB |
Output is correct |
54 |
Correct |
1 ms |
848 KB |
Output is correct |
55 |
Correct |
6 ms |
848 KB |
Output is correct |
56 |
Correct |
87 ms |
856 KB |
Output is correct |
57 |
Correct |
87 ms |
848 KB |
Output is correct |
58 |
Correct |
1 ms |
848 KB |
Output is correct |
59 |
Correct |
1 ms |
848 KB |
Output is correct |
60 |
Correct |
6 ms |
832 KB |
Output is correct |
61 |
Correct |
86 ms |
836 KB |
Output is correct |
62 |
Correct |
1 ms |
848 KB |
Output is correct |
63 |
Runtime error |
396 ms |
262144 KB |
Execution killed with signal 9 |
64 |
Halted |
0 ms |
0 KB |
- |