Submission #40950

# Submission time Handle Problem Language Result Execution time Memory
40950 2018-02-09T23:51:08 Z IvanC Bali Sculptures (APIO15_sculpture) C++14
75 / 100
1000 ms 876 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2010;
const int MAXM = 110;
int dp[MAXN],N,A,B;
bool tab[MAXM][MAXM],possivel;
ll soma[MAXN],proibido,atual;
ll calc(ll a,ll b){return soma[b] - soma[a-1];}
int solve(int pos){
	if(dp[pos] != -1) return dp[pos];
	if(pos == N + 1) return dp[pos] = 0;
	int best = MAXN;
	for(int quebra = pos;quebra<=N;quebra++){
		if((calc(pos,quebra)) & proibido) continue;
		best = min(best, 1 + solve(quebra+1));
	}
	return dp[pos] = best;
}
void check(int pos,int resta){
	if(possivel) return;
	if(tab[pos][resta]) return;
	if(pos == N + 1 && resta == 0) possivel = true;
	if(resta == 0 || pos == N+1) return;
	for(int quebra = pos;quebra<=N;quebra++){
		if((calc(pos,quebra)) & proibido) continue;
		check(quebra+1,resta - 1);
	}
}
int main(){
	cin >> N >> A >> B;
	if(A == 1){
		for(int i = 1;i<=N;i++){
			cin >> soma[i];
			soma[i] += soma[i-1];
		}
		for(ll i = 41;i>=0;i--){
			proibido |= (1LL << i);
			memset(dp,-1,sizeof(dp));
			if(solve(1) > B){
				proibido ^= (1LL << i);
				atual |= (1LL << i);
			}
		}
		cout << atual << endl;
	}
	else{
		for(int i = 1;i<=N;i++){
			cin >> soma[i];
			soma[i] += soma[i-1];
		}
		for(ll i = 37;i>=0;i--){
			proibido |= (1LL << i);
			memset(tab,false,sizeof(tab));
			possivel = false;
			for(int j = A;j<=B;j++) check(1,j);
			if(!possivel){
				proibido ^= (1LL << i);
				atual |= (1LL << i);
			}
		}
		cout << atual << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 628 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 1 ms 628 KB Output is correct
9 Correct 2 ms 628 KB Output is correct
10 Correct 2 ms 628 KB Output is correct
11 Correct 1 ms 628 KB Output is correct
12 Correct 2 ms 628 KB Output is correct
13 Correct 2 ms 628 KB Output is correct
14 Correct 2 ms 628 KB Output is correct
15 Correct 1 ms 628 KB Output is correct
16 Correct 1 ms 628 KB Output is correct
17 Correct 1 ms 628 KB Output is correct
18 Correct 2 ms 628 KB Output is correct
19 Correct 2 ms 628 KB Output is correct
20 Correct 2 ms 628 KB Output is correct
21 Correct 2 ms 628 KB Output is correct
22 Correct 2 ms 692 KB Output is correct
23 Correct 2 ms 692 KB Output is correct
24 Correct 2 ms 692 KB Output is correct
25 Correct 2 ms 692 KB Output is correct
26 Correct 2 ms 692 KB Output is correct
27 Correct 1 ms 692 KB Output is correct
28 Correct 2 ms 692 KB Output is correct
29 Correct 2 ms 692 KB Output is correct
30 Correct 2 ms 692 KB Output is correct
31 Correct 2 ms 692 KB Output is correct
32 Correct 1 ms 692 KB Output is correct
33 Correct 2 ms 692 KB Output is correct
34 Correct 2 ms 692 KB Output is correct
35 Correct 2 ms 692 KB Output is correct
36 Correct 1 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 692 KB Output is correct
2 Correct 1 ms 692 KB Output is correct
3 Correct 1 ms 692 KB Output is correct
4 Correct 2 ms 692 KB Output is correct
5 Correct 1 ms 692 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 2 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 2 ms 692 KB Output is correct
12 Correct 2 ms 692 KB Output is correct
13 Correct 2 ms 692 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 1 ms 732 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 1 ms 732 KB Output is correct
19 Correct 2 ms 732 KB Output is correct
20 Correct 1 ms 732 KB Output is correct
21 Correct 2 ms 732 KB Output is correct
22 Correct 1 ms 732 KB Output is correct
23 Correct 2 ms 732 KB Output is correct
24 Correct 2 ms 732 KB Output is correct
25 Correct 2 ms 732 KB Output is correct
26 Correct 2 ms 732 KB Output is correct
27 Correct 2 ms 732 KB Output is correct
28 Correct 2 ms 732 KB Output is correct
29 Correct 2 ms 732 KB Output is correct
30 Correct 2 ms 732 KB Output is correct
31 Correct 2 ms 732 KB Output is correct
32 Correct 2 ms 732 KB Output is correct
33 Correct 2 ms 732 KB Output is correct
34 Correct 2 ms 732 KB Output is correct
35 Correct 2 ms 732 KB Output is correct
36 Correct 2 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 732 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 2 ms 732 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 1 ms 732 KB Output is correct
6 Correct 2 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 1 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 1 ms 732 KB Output is correct
15 Correct 1 ms 732 KB Output is correct
16 Correct 2 ms 732 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 732 KB Output is correct
20 Correct 2 ms 732 KB Output is correct
21 Correct 2 ms 732 KB Output is correct
22 Correct 2 ms 732 KB Output is correct
23 Correct 2 ms 732 KB Output is correct
24 Correct 2 ms 732 KB Output is correct
25 Correct 2 ms 732 KB Output is correct
26 Correct 3 ms 732 KB Output is correct
27 Correct 2 ms 732 KB Output is correct
28 Correct 2 ms 732 KB Output is correct
29 Correct 3 ms 732 KB Output is correct
30 Correct 3 ms 732 KB Output is correct
31 Correct 3 ms 732 KB Output is correct
32 Correct 3 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 732 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 1 ms 732 KB Output is correct
4 Correct 1 ms 732 KB Output is correct
5 Correct 1 ms 732 KB Output is correct
6 Correct 1 ms 732 KB Output is correct
7 Correct 1 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 1 ms 732 KB Output is correct
10 Correct 1 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 1 ms 732 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 2 ms 732 KB Output is correct
15 Correct 2 ms 732 KB Output is correct
16 Correct 2 ms 732 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 732 KB Output is correct
20 Correct 1 ms 732 KB Output is correct
21 Correct 2 ms 732 KB Output is correct
22 Correct 1 ms 740 KB Output is correct
23 Correct 2 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 1 ms 740 KB Output is correct
26 Correct 1 ms 740 KB Output is correct
27 Correct 2 ms 740 KB Output is correct
28 Correct 1 ms 740 KB Output is correct
29 Correct 1 ms 740 KB Output is correct
30 Correct 1 ms 740 KB Output is correct
31 Correct 2 ms 740 KB Output is correct
32 Correct 2 ms 740 KB Output is correct
33 Correct 2 ms 740 KB Output is correct
34 Correct 2 ms 740 KB Output is correct
35 Correct 1 ms 740 KB Output is correct
36 Correct 2 ms 740 KB Output is correct
37 Correct 2 ms 740 KB Output is correct
38 Correct 2 ms 740 KB Output is correct
39 Correct 2 ms 740 KB Output is correct
40 Correct 2 ms 740 KB Output is correct
41 Correct 2 ms 740 KB Output is correct
42 Correct 2 ms 740 KB Output is correct
43 Correct 2 ms 740 KB Output is correct
44 Correct 2 ms 740 KB Output is correct
45 Correct 2 ms 740 KB Output is correct
46 Correct 2 ms 740 KB Output is correct
47 Correct 2 ms 740 KB Output is correct
48 Correct 2 ms 740 KB Output is correct
49 Correct 2 ms 740 KB Output is correct
50 Correct 2 ms 740 KB Output is correct
51 Correct 2 ms 740 KB Output is correct
52 Correct 2 ms 740 KB Output is correct
53 Correct 2 ms 740 KB Output is correct
54 Correct 3 ms 740 KB Output is correct
55 Correct 3 ms 740 KB Output is correct
56 Correct 2 ms 740 KB Output is correct
57 Correct 2 ms 740 KB Output is correct
58 Correct 2 ms 740 KB Output is correct
59 Correct 2 ms 740 KB Output is correct
60 Correct 2 ms 740 KB Output is correct
61 Correct 2 ms 740 KB Output is correct
62 Correct 2 ms 740 KB Output is correct
63 Correct 2 ms 740 KB Output is correct
64 Execution timed out 1056 ms 740 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 740 KB Output is correct
2 Correct 1 ms 740 KB Output is correct
3 Correct 1 ms 740 KB Output is correct
4 Correct 1 ms 740 KB Output is correct
5 Correct 1 ms 740 KB Output is correct
6 Correct 1 ms 740 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 1 ms 740 KB Output is correct
9 Correct 1 ms 740 KB Output is correct
10 Correct 1 ms 740 KB Output is correct
11 Correct 1 ms 740 KB Output is correct
12 Correct 1 ms 740 KB Output is correct
13 Correct 1 ms 740 KB Output is correct
14 Correct 2 ms 740 KB Output is correct
15 Correct 1 ms 740 KB Output is correct
16 Correct 2 ms 740 KB Output is correct
17 Correct 1 ms 740 KB Output is correct
18 Correct 2 ms 740 KB Output is correct
19 Correct 1 ms 740 KB Output is correct
20 Correct 1 ms 740 KB Output is correct
21 Correct 1 ms 740 KB Output is correct
22 Correct 2 ms 740 KB Output is correct
23 Correct 1 ms 740 KB Output is correct
24 Correct 2 ms 740 KB Output is correct
25 Correct 1 ms 740 KB Output is correct
26 Correct 1 ms 740 KB Output is correct
27 Correct 2 ms 740 KB Output is correct
28 Correct 2 ms 740 KB Output is correct
29 Correct 2 ms 740 KB Output is correct
30 Correct 2 ms 740 KB Output is correct
31 Correct 2 ms 740 KB Output is correct
32 Correct 2 ms 744 KB Output is correct
33 Correct 2 ms 744 KB Output is correct
34 Correct 2 ms 744 KB Output is correct
35 Correct 2 ms 744 KB Output is correct
36 Correct 2 ms 744 KB Output is correct
37 Correct 2 ms 744 KB Output is correct
38 Correct 3 ms 744 KB Output is correct
39 Correct 3 ms 744 KB Output is correct
40 Correct 2 ms 744 KB Output is correct
41 Correct 2 ms 744 KB Output is correct
42 Correct 2 ms 744 KB Output is correct
43 Correct 1 ms 744 KB Output is correct
44 Correct 2 ms 744 KB Output is correct
45 Correct 2 ms 744 KB Output is correct
46 Correct 2 ms 744 KB Output is correct
47 Correct 2 ms 744 KB Output is correct
48 Correct 2 ms 744 KB Output is correct
49 Correct 3 ms 744 KB Output is correct
50 Correct 2 ms 744 KB Output is correct
51 Correct 2 ms 744 KB Output is correct
52 Correct 11 ms 744 KB Output is correct
53 Correct 10 ms 744 KB Output is correct
54 Correct 36 ms 748 KB Output is correct
55 Correct 33 ms 748 KB Output is correct
56 Correct 63 ms 812 KB Output is correct
57 Correct 53 ms 812 KB Output is correct
58 Correct 65 ms 812 KB Output is correct
59 Correct 82 ms 876 KB Output is correct
60 Correct 78 ms 876 KB Output is correct
61 Correct 2 ms 876 KB Output is correct
62 Correct 10 ms 876 KB Output is correct
63 Correct 35 ms 876 KB Output is correct
64 Correct 16 ms 876 KB Output is correct
65 Correct 29 ms 876 KB Output is correct
66 Correct 41 ms 876 KB Output is correct
67 Correct 58 ms 876 KB Output is correct
68 Correct 123 ms 876 KB Output is correct
69 Correct 62 ms 876 KB Output is correct