CSES - APIO 2015 - Results
Submission details
Task:Bali Sculptures
Sender:Olli
Submission time:2019-04-07 15:58:29 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#1ACCEPTED0.02 s1, 2, 3, 4, 5details
#20.02 s1, 2, 3, 4, 5details
#3ACCEPTED0.01 s1, 2, 3, 4, 5details
#40.01 s1, 2, 3, 4, 5details
#5ACCEPTED0.02 s1, 2, 3, 4, 5details
#6ACCEPTED0.02 s1, 2, 3, 4, 5details
#7ACCEPTED0.02 s1, 2, 3, 4, 5details
#8ACCEPTED0.02 s1, 2, 3, 4, 5details
#9ACCEPTED0.02 s1, 2, 3, 4, 5details
#100.03 s1, 2, 3, 4, 5details
#11ACCEPTED0.02 s1, 2, 3, 4, 5details
#12ACCEPTED0.01 s1, 2, 3, 4, 5details
#13ACCEPTED0.03 s1, 2, 4details
#14ACCEPTED0.01 s1, 2, 4details
#15ACCEPTED0.02 s1, 2, 4details
#16ACCEPTED0.02 s1, 2, 4details
#17ACCEPTED0.02 s1, 2, 4details
#18ACCEPTED0.02 s1, 2, 4details
#19ACCEPTED0.03 s1, 2, 4details
#20ACCEPTED0.01 s1, 2, 4details
#21ACCEPTED0.01 s1, 2, 4details
#22ACCEPTED0.02 s1, 2, 4details
#23ACCEPTED0.02 s1, 2, 4details
#24ACCEPTED0.03 s1, 2, 4details
#25ACCEPTED0.02 s1, 2, 4details
#26ACCEPTED0.01 s1, 4, 5details
#27ACCEPTED0.02 s1, 4, 5details
#28ACCEPTED0.03 s1, 4, 5details
#29ACCEPTED0.02 s1, 4, 5details
#30ACCEPTED0.02 s1, 4, 5details
#310.01 s1, 4, 5details
#32ACCEPTED0.02 s1, 4, 5details
#33ACCEPTED0.01 s1, 4, 5details
#34ACCEPTED0.02 s1, 4, 5details
#35ACCEPTED0.03 s1, 4, 5details
#36ACCEPTED0.03 s2, 3, 4, 5details
#37ACCEPTED0.02 s2, 3, 4, 5details
#38ACCEPTED0.01 s2, 3, 4, 5details
#39ACCEPTED0.02 s2, 3, 4, 5details
#40ACCEPTED0.03 s2, 3, 4, 5details
#41ACCEPTED0.01 s2, 3, 4, 5details
#420.02 s2, 3, 4, 5details
#43ACCEPTED0.02 s2, 3, 4, 5details
#44ACCEPTED0.03 s2, 3, 4, 5details
#45ACCEPTED0.02 s2, 3, 4, 5details
#46ACCEPTED0.01 s3, 4, 5details
#47ACCEPTED0.02 s3, 4, 5details
#48ACCEPTED0.03 s3, 4, 5details
#49ACCEPTED0.03 s3, 4, 5details
#50ACCEPTED0.04 s3, 4, 5details
#51ACCEPTED0.04 s3, 4, 5details
#520.04 s3, 4, 5details
#53ACCEPTED0.04 s3, 4, 5details
#54ACCEPTED0.03 s3, 4, 5details
#55ACCEPTED0.02 s4, 5details
#56ACCEPTED0.04 s4, 5details
#57ACCEPTED0.05 s4, 5details
#58ACCEPTED0.06 s4, 5details
#59ACCEPTED0.07 s4, 5details
#600.03 s4, 5details
#61ACCEPTED0.06 s4, 5details
#62ACCEPTED0.05 s4, 5details
#63ACCEPTED0.04 s4details
#64ACCEPTED0.03 s4details
#65ACCEPTED0.03 s4details
#66ACCEPTED0.04 s4details
#67ACCEPTED0.04 s4details
#68ACCEPTED0.07 s4details
#69ACCEPTED0.06 s4details
#70ACCEPTED0.04 s4details
#71ACCEPTED0.06 s4details
#72ACCEPTED0.06 s4details
#73ACCEPTED0.06 s4details
#74ACCEPTED0.04 s5details
#750.02 s5details
#760.02 s5details
#770.02 s5details
#780.03 s5details
#790.02 s5details
#800.01 s5details
#810.01 s5details
#820.02 s5details
#830.02 s5details
#84ACCEPTED0.04 s5details
#850.02 s5details
#860.01 s5details
#870.02 s5details
#880.02 s5details
#890.01 s5details
#900.01 s5details
#910.02 s5details
#920.01 s5details

Code

#include <iostream>

using namespace std;

typedef long long ll;

const int N = 111;

int n, a, b;
ll y[N];
ll sum[N];

bool isOk(ll V, ll x) {
	while(V%2 == 0) {
		V/=2; x/=2;
	}
	if(x%2 == 1) return false;
	while(V > 0) {
		if(V%2 == 0 && x%2 == 1) {
			return false;
		}
		x /= 2; V /= 2;
	}
	if(x > 0) return false;
	return true;
}

bool can(ll V) {
	bool ok[N][N];
	for(int A = 1; A <= n; ++A) {
		for(int B = A; B <= n; ++B) {
			ok[A][B] = isOk(V, sum[B] - sum[A-1]);
		}
	}

/*	if(V <= 20) {
		for(int A = 1; A <= n; ++A) {
			for(int B = A; B <= n; ++B) {
				cout << ok[A][B] << " ";
			}
			cout << "\n";
		}
		cout << "\n\n";
	}
*/

	bool ca[N][N];
	for(int i = 1; i <= n; ++i) {
		if(ok[i][n]) {
			ca[1][i] = true;
		} else {
			ca[1][i] = false;
		}
	}

	for(int am = 2; am <= b; ++am) {
		for(int i = n; i >= 1; --i) {
			ca[am][i] = false;
			for(int j = i; j < n; ++j) {
				if(ok[i][j] && ca[am-1][j+1]) {
					ca[am][i] = true;
				}
			}
		}
		if(ca[am][1] && am >= a && am <= b) {
			return true;
		}
	}
	return false;
}

int main() {
	cin >> n >> a >> b;
	for(int i = 1; i <= n; ++i) {
		cin >> y[i];
		sum[i] = sum[i-1] + y[i];
	}

	ll cur = 0;
	for(ll bit = 45; bit >= 0; --bit) {
		ll ne = ((ll) 1) << bit;
		ne += cur;
		bool c = can(ne);
		if(!c) {
			cur = ne;
		}
	}

	cout << cur << "\n";
}

Test details

Test 1

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
8 1 4
1 2 1 1 1 0 4 6

correct output
6

user output
6

Test 2

Group: 1, 2, 3, 4, 5

Verdict:

input
1 1 1
0

correct output
0

user output
70368744177663

Test 3

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
5 1 3
3 4 8 8 6

correct output
15

user output
15

Test 4

Group: 1, 2, 3, 4, 5

Verdict:

input
10 1 1
9 7 3 3 7 9 0 9 1 4

correct output
52

user output
70368744177663

Test 5

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
15 1 15
0 7 4 1 3 1 0 5 4 3 9 1 3 1 3

correct output
11

user output
11

Test 6

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
17 1 3
10 5 7 3 5 9 0 10 10 7 6 3 3 0...

correct output
47

user output
47

Test 7

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1 3
3 0 9 7 1 2 6 0 0 2 1 8 5 5 3 ...

correct output
43

user output
43

Test 8

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1 3
9 9 8 8 10 8 8 8 8 9 9 8 8 8 9...

correct output
62

user output
62

Test 9

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1 3
10 10 10 10 10 10 10 10 10 10 ...

correct output
94

user output
94

Test 10

Group: 1, 2, 3, 4, 5

Verdict:

input
20 1 1
10 10 10 10 10 10 10 10 10 10 ...

correct output
200

user output
70368744177663

Test 11

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1 3
8 1 1 1 8 2 2 4 2 8 8 1 4 1 1 ...

correct output
27

user output
27

Test 12

Group: 1, 2, 3, 4, 5

Verdict: ACCEPTED

input
20 1 17
4 2 4 1 8 8 4 1 4 2 2 1 1 2 1 ...

correct output
11

user output
11

Test 13

Group: 1, 2, 4

Verdict: ACCEPTED

input
6 2 3
1 1 1 1 1 1

correct output
2

user output
2

Test 14

Group: 1, 2, 4

Verdict: ACCEPTED

input
6 6 6
0 0 0 1 1 2

correct output
3

user output
3

Test 15

Group: 1, 2, 4

Verdict: ACCEPTED

input
6 3 6
6 5 0 0 0 1

correct output
7

user output
7

Test 16

Group: 1, 2, 4

Verdict: ACCEPTED

input
5 2 3
7 5 6 9 8

correct output
15

user output
15

Test 17

Group: 1, 2, 4

Verdict: ACCEPTED

input
10 2 4
9 6 6 9 6 1 3 2 5 2

correct output
15

user output
15

Test 18

Group: 1, 2, 4

Verdict: ACCEPTED

input
15 15 15
4 9 8 4 5 7 1 5 3 7 10 5 4 2 4

correct output
15

user output
15

Test 19

Group: 1, 2, 4

Verdict: ACCEPTED

input
17 3 3
3 6 7 9 9 5 7 5 6 2 6 2 10 8 7...

correct output
43

user output
43

Test 20

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 4 7
9 8 7 2 10 1 3 2 5 0 10 3 6 5 ...

correct output
19

user output
19

Test 21

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 4 7
10 10 8 10 9 10 10 8 10 9 9 8 ...

correct output
31

user output
31

Test 22

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 4 7
10 10 10 10 10 10 10 10 10 10 ...

correct output
30

user output
30

Test 23

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 2 2
10 10 10 10 10 10 10 10 10 10 ...

correct output
100

user output
100

Test 24

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 2 7
1 4 8 1 4 4 1 1 2 8 2 2 4 1 1 ...

correct output
13

user output
13

Test 25

Group: 1, 2, 4

Verdict: ACCEPTED

input
20 5 13
1 4 8 1 2 8 1 1 8 8 8 4 4 2 2 ...

correct output
15

user output
15

Test 26

Group: 1, 4, 5

Verdict: ACCEPTED

input
5 1 3
484935714 268992075 426899299 ...

correct output
1023340543

user output
1023340543

Test 27

Group: 1, 4, 5

Verdict: ACCEPTED

input
10 1 4
628673248 923554466 802711954 ...

correct output
1744830461

user output
1744830461

Test 28

Group: 1, 4, 5

Verdict: ACCEPTED

input
13 1 13
606300077 908667444 394321231 ...

correct output
1073741823

user output
1073741823

Test 29

Group: 1, 4, 5

Verdict: ACCEPTED

input
19 1 3
784661819 844802233 537453129 ...

correct output
4290772959

user output
4290772959

Test 30

Group: 1, 4, 5

Verdict: ACCEPTED

input
20 1 7
1000000000 1000000000 10000000...

correct output
4000000000

user output
4000000000

Test 31

Group: 1, 4, 5

Verdict:

input
20 1 1
1000000000 1000000000 10000000...

correct output
20000000000

user output
70368744177663

Test 32

Group: 1, 4, 5

Verdict: ACCEPTED

input
20 1 13
16384 256 4194304 524288 4096 ...

correct output
384325888

user output
384325888

Test 33

Group: 1, 4, 5

Verdict: ACCEPTED

input
20 1 20
32 536870912 8192 131072 41943...

correct output
547320608

user output
547320608

Test 34

Group: 1, 4, 5

Verdict: ACCEPTED

input
20 1 3
16777216 262144 128 32 1024 16...

correct output
536207264

user output
536207264

Test 35

Group: 1, 4, 5

Verdict: ACCEPTED

input
20 1 20
256 33554432 128 8192 131072 8...

correct output
1073472416

user output
1073472416

Test 36

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
21 1 20
2 8 9 5 5 2 8 3 0 5 0 5 9 3 4 ...

correct output
15

user output
15

Test 37

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
25 1 10
0 8 2 7 2 6 9 10 3 4 1 4 8 4 4...

correct output
23

user output
23

Test 38

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
38 1 5
8 8 4 5 5 3 7 10 6 1 3 10 3 2 ...

correct output
46

user output
46

Test 39

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
42 1 18
4 4 7 2 9 5 6 0 1 9 5 3 2 8 0 ...

correct output
15

user output
15

Test 40

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
50 1 20
8 8 9 10 10 8 9 8 8 9 10 9 8 1...

correct output
31

user output
31

Test 41

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
50 1 20
10 10 10 10 10 10 10 10 10 10 ...

correct output
30

user output
30

Test 42

Group: 2, 3, 4, 5

Verdict:

input
50 1 1
10 10 10 10 10 10 10 10 10 10 ...

correct output
500

user output
70368744177663

Test 43

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
50 1 20
2 2 6 1 8 4 10 1 2 4 1 3 4 5 5...

correct output
15

user output
15

Test 44

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
50 1 17
4 10 3 4 2 8 6 6 4 2 8 8 5 4 9...

correct output
23

user output
23

Test 45

Group: 2, 3, 4, 5

Verdict: ACCEPTED

input
50 1 10
8 8 6 4 10 8 2 2 5 4 6 3 3 7 2...

correct output
31

user output
31

Test 46

Group: 3, 4, 5

Verdict: ACCEPTED

input
51 1 20
6 10 12 9 0 3 14 3 0 1 18 20 4...

correct output
31

user output
31

Test 47

Group: 3, 4, 5

Verdict: ACCEPTED

input
65 1 10
4 4 16 20 4 4 1 16 19 7 7 6 7 ...

correct output
79

user output
79

Test 48

Group: 3, 4, 5

Verdict: ACCEPTED

input
78 1 23
1 7 6 6 16 19 4 1 3 19 4 11 14...

correct output
47

user output
47

Test 49

Group: 3, 4, 5

Verdict: ACCEPTED

input
91 1 55
17 10 12 19 18 1 10 7 15 15 10...

correct output
31

user output
31

Test 50

Group: 3, 4, 5

Verdict: ACCEPTED

input
100 1 100
14 12 3 1 15 7 6 13 16 16 0 2 ...

correct output
31

user output
31

Test 51

Group: 3, 4, 5

Verdict: ACCEPTED

input
100 1 100
20 20 20 20 20 20 20 20 20 20 ...

correct output
20

user output
20

Test 52

Group: 3, 4, 5

Verdict:

input
100 1 1
20 20 20 20 20 20 20 20 20 20 ...

correct output
2000

user output
70368744177663

Test 53

Group: 3, 4, 5

Verdict: ACCEPTED

input
100 1 47
18 1 15 15 2 14 19 16 8 19 1 7...

correct output
47

user output
47

Test 54

Group: 3, 4, 5

Verdict: ACCEPTED

input
100 1 74
18 7 6 16 5 12 15 13 20 18 20 ...

correct output
31

user output
31

Test 55

Group: 4, 5

Verdict: ACCEPTED

input
51 1 20
121196387 793437174 733664347 ...

correct output
2143289343

user output
2143289343

Test 56

Group: 4, 5

Verdict: ACCEPTED

input
78 1 23
338917195 45092218 991962249 5...

correct output
2147483647

user output
2147483647

Test 57

Group: 4, 5

Verdict: ACCEPTED

input
91 1 55
864333343 206114644 126507950 ...

correct output
1073741823

user output
1073741823

Test 58

Group: 4, 5

Verdict: ACCEPTED

input
100 1 100
963428291 63818745 221600859 3...

correct output
1073741823

user output
1073741823

Test 59

Group: 4, 5

Verdict: ACCEPTED

input
100 1 100
1000000000 1000000000 10000000...

correct output
1000000000

user output
1000000000

Test 60

Group: 4, 5

Verdict:

input
100 1 1
1000000000 1000000000 10000000...

correct output
100000000000

user output
70368744177663

Test 61

Group: 4, 5

Verdict: ACCEPTED

input
100 1 100
4729857 16400 9744 524296 4204...

correct output
1040187359

user output
1040187359

Test 62

Group: 4, 5

Verdict: ACCEPTED

input
100 1 100
524800 268435472 3153920 52896...

correct output
1006630911

user output
1006630911

Test 63

Group: 4

Verdict: ACCEPTED

input
90 45 90
0 0 0 1 1 2 0 0 0 1 1 2 0 0 0 ...

correct output
2

user output
2

Test 64

Group: 4

Verdict: ACCEPTED

input
51 11 20
338656497 283890494 150485552 ...

correct output
2139095039

user output
2139095039

Test 65

Group: 4

Verdict: ACCEPTED

input
65 2 10
425384156 386493235 539305167 ...

correct output
3154116607

user output
3154116607

Test 66

Group: 4

Verdict: ACCEPTED

input
78 2 23
840979497 86262996 486127502 1...

correct output
3087007743

user output
3087007743

Test 67

Group: 4

Verdict: ACCEPTED

input
91 19 55
809793899 214508559 841918281 ...

correct output
2147483135

user output
2147483135

Test 68

Group: 4

Verdict: ACCEPTED

input
100 57 100
196269864 268098408 244902537 ...

correct output
1073741823

user output
1073741823

Test 69

Group: 4

Verdict: ACCEPTED

input
100 57 100
1000000000 1000000000 10000000...

correct output
1000000000

user output
1000000000

Test 70

Group: 4

Verdict: ACCEPTED

input
100 2 2
1000000000 1000000000 10000000...

correct output
50000000000

user output
50000000000

Test 71

Group: 4

Verdict: ACCEPTED

input
100 2 100
570425344 74752 312541184 5190...

correct output
1006632927

user output
1006632927

Test 72

Group: 4

Verdict: ACCEPTED

input
100 47 74
16777571 268439560 67108864 13...

correct output
1073676287

user output
1073676287

Test 73

Group: 4

Verdict: ACCEPTED

input
100 33 66
554434568 42500608 541065216 3...

correct output
1065352959

user output
1065352959

Test 74

Group: 5

Verdict: ACCEPTED

input
101 1 20
85935224 323057267 117347452 1...

correct output
3187671039

user output
3187671039

Test 75

Group: 5

Verdict:

input
575 1 99
77324562 741204988 396285802 5...

correct output
3221225471

user output
0

Test 76

Group: 5

Verdict:

input
747 1 747
165703035 239516466 247451396 ...

correct output
1073741823

user output
(empty)

Test 77

Group: 5

Verdict:

input
999 1 20
770032430 298850322 436841858 ...

correct output
25633488895

user output
70368744177663

Test 78

Group: 5

Verdict:

input
1000 1 55
421970300 595156571 662138730 ...

correct output
9663676415

user output
0

Test 79

Group: 5

Verdict:

input
2000 1 1000
180685541 530949040 41342815 2...

correct output
2147483647

user output
(empty)

Test 80

Group: 5

Verdict:

input
2000 1 2000
372443635 870265368 711491467 ...

correct output
1073741823

user output
0

Test 81

Group: 5

Verdict:

input
2000 1 2000
999999340 999999681 999999964 ...

correct output
1000001535

user output
(empty)

Test 82

Group: 5

Verdict:

input
2000 1 2000
1000000000 1000000000 10000000...

correct output
1000000000

user output
(empty)

Test 83

Group: 5

Verdict:

input
2000 1 1
1000000000 1000000000 10000000...

correct output
2000000000000

user output
(empty)

Test 84

Group: 5

Verdict: ACCEPTED

input
101 1 20
555761664 2098187 134234368 54...

correct output
1073676287

user output
1073676287

Test 85

Group: 5

Verdict:

input
747 1 747
67371040 765321087 323789972 7...

correct output
1073741823

user output
70368744177663

Test 86

Group: 5

Verdict:

input
999 1 20
819971511 671088634 273052483 ...

correct output
29796335615

user output
70368744177663

Test 87

Group: 5

Verdict:

input
1000 1 1000
299890687 530448375 117474515 ...

correct output
1073741823

user output
(empty)

Test 88

Group: 5

Verdict:

input
1404 1 400
985503341 469745388 805302143 ...

correct output
3221225471

user output
(empty)

Test 89

Group: 5

Verdict:

input
1747 1 1747
503169023 620622781 994050047 ...

correct output
1073741823

user output
(empty)

Test 90

Group: 5

Verdict:

input
2000 1 1
939524095 989853695 939259903 ...

correct output
1376705763223

user output
(empty)

Test 91

Group: 5

Verdict:

input
2000 1 55
997711727 939524079 935329759 ...

correct output
25769803775

user output
(empty)

Test 92

Group: 5

Verdict:

input
2000 1 2000
805306367 939524087 536875520 ...

correct output
1073741823

user output
70368744177663