Submission #211771

# Submission time Handle Problem Language Result Execution time Memory
211771 2020-03-21T08:13:30 Z nvmdava Remittance (JOI19_remittance) C++17
100 / 100
670 ms 31864 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000002
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007LL
 
ll d[N], a[N], b[N], c[N];
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
    	cin>>a[i]>>b[i];
    	c[i] = a[i] - b[i];
    }
    
 
    for(int j = 0; j < 30; ++j){
    	for(int i = 1; i <= n; ++i){
    		if(c[i] % 2 != 0){
    			d[i - 1] += 1LL << j;
    		}
    	}
 	   	d[n] = d[0];
    	for(int i = 1; i <= n; ++i){
    		if(d[i] & (1LL << j)){
    			c[i] -= 2;
    			if(i == n)
    				c[1]++;
    			else
	    			++c[i + 1];
    		}
    	}
    	for(int i = 1; i <= n; ++i){
    		c[i] /= 2;
    	}
    }
    for(int j = 1; j <= 3; ++j){
	    for(int i = 1; i <= n; ++i){
	    	if(d[i] && a[i] > 1){
	    		ll k = min(d[i], a[i] / 2);
	    		d[i] -= k;
	    		a[i] -= k * 2;
	    		if(i != n)
	    			a[i + 1] += k;
	    		else 
	    			a[1] += k;
	    	}
	    }
    }
    for(int i = 1; i <= n; ++i){
    	if(a[i] != b[i]){
    		cout<<"No";
    		return 0;
    	}
    }
    cout<<"Yes";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 416 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 416 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 4 ms 256 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 4 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 4 ms 384 KB Output is correct
55 Correct 4 ms 384 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 4 ms 384 KB Output is correct
58 Correct 4 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 416 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 4 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 4 ms 256 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 4 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 4 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 4 ms 384 KB Output is correct
55 Correct 4 ms 384 KB Output is correct
56 Correct 5 ms 384 KB Output is correct
57 Correct 4 ms 384 KB Output is correct
58 Correct 4 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 5 ms 384 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 666 ms 31608 KB Output is correct
64 Correct 251 ms 31864 KB Output is correct
65 Correct 657 ms 31736 KB Output is correct
66 Correct 228 ms 31608 KB Output is correct
67 Correct 267 ms 31608 KB Output is correct
68 Correct 344 ms 31864 KB Output is correct
69 Correct 644 ms 31608 KB Output is correct
70 Correct 249 ms 31692 KB Output is correct
71 Correct 277 ms 31608 KB Output is correct
72 Correct 341 ms 31736 KB Output is correct
73 Correct 649 ms 31608 KB Output is correct
74 Correct 251 ms 31736 KB Output is correct
75 Correct 263 ms 31612 KB Output is correct
76 Correct 346 ms 31736 KB Output is correct
77 Correct 637 ms 31736 KB Output is correct
78 Correct 582 ms 31660 KB Output is correct
79 Correct 578 ms 31608 KB Output is correct
80 Correct 583 ms 31608 KB Output is correct
81 Correct 597 ms 31688 KB Output is correct
82 Correct 222 ms 31608 KB Output is correct
83 Correct 237 ms 31736 KB Output is correct
84 Correct 208 ms 23800 KB Output is correct
85 Correct 670 ms 31812 KB Output is correct
86 Correct 660 ms 31736 KB Output is correct
87 Correct 309 ms 31608 KB Output is correct
88 Correct 358 ms 31672 KB Output is correct