#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 105;
const int MAXOR = 4097;
int dp[MAXN][MAXN][MAXOR];
unordered_set<ll> dp1[MAXN][MAXN];
int N,A,B;
ll soma[MAXN],best;
ll calc(int a,int b){return soma[b] - soma[a-1];}
void solve1(int pos,int resta,ll curOr){
if(resta < 0) return;
if(dp1[pos][resta].count(curOr)) return;
dp1[pos][resta].insert(curOr);
if(pos == N + 1){
if(resta != 0) return;
best = min(best,curOr);
return;
}
if(resta == 0) return;
for(int quebra = pos;quebra<=N;quebra++){
solve1(quebra+1,resta - 1,curOr | calc(pos,quebra));
}
}
void solve(int pos,int resta,ll curOr){
if(dp[pos][resta][curOr]) return;
dp[pos][resta][curOr] = 1;
if(pos == N + 1){
if(resta != 0) return;
best = min(best,curOr);
return;
}
if(resta == 0) return;
for(int quebra = pos;quebra<=N;quebra++){
solve(quebra+1,resta - 1,curOr | calc(pos,quebra));
}
}
int main(){
scanf("%d %d %d",&N,&A,&B);
for(int i = 1;i<=N;i++){
scanf("%lld",&soma[i]);
soma[i] += soma[i-1];
}
best = (ll)1e18;
if(N <= 20){
for(int i = A;i<=B;i++) solve1(1,i,0);
printf("%lld\n",best);
return 0;
}
for(int i = A;i<=B;i++) solve(1,i,0);
printf("%lld\n",best);
return 0;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:39:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&N,&A,&B);
^
sculpture.cpp:41:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&soma[i]);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
2 ms |
1120 KB |
Output is correct |
3 |
Correct |
2 ms |
1120 KB |
Output is correct |
4 |
Correct |
2 ms |
1120 KB |
Output is correct |
5 |
Correct |
2 ms |
1120 KB |
Output is correct |
6 |
Correct |
2 ms |
1124 KB |
Output is correct |
7 |
Correct |
2 ms |
1124 KB |
Output is correct |
8 |
Correct |
2 ms |
1176 KB |
Output is correct |
9 |
Correct |
2 ms |
1176 KB |
Output is correct |
10 |
Correct |
2 ms |
1176 KB |
Output is correct |
11 |
Correct |
2 ms |
1176 KB |
Output is correct |
12 |
Correct |
2 ms |
1176 KB |
Output is correct |
13 |
Correct |
3 ms |
1244 KB |
Output is correct |
14 |
Correct |
2 ms |
1244 KB |
Output is correct |
15 |
Correct |
2 ms |
1244 KB |
Output is correct |
16 |
Correct |
2 ms |
1244 KB |
Output is correct |
17 |
Correct |
2 ms |
1244 KB |
Output is correct |
18 |
Correct |
2 ms |
1244 KB |
Output is correct |
19 |
Correct |
2 ms |
1244 KB |
Output is correct |
20 |
Correct |
2 ms |
1244 KB |
Output is correct |
21 |
Correct |
2 ms |
1260 KB |
Output is correct |
22 |
Correct |
2 ms |
1260 KB |
Output is correct |
23 |
Correct |
2 ms |
1260 KB |
Output is correct |
24 |
Correct |
2 ms |
1260 KB |
Output is correct |
25 |
Correct |
2 ms |
1292 KB |
Output is correct |
26 |
Correct |
3 ms |
1292 KB |
Output is correct |
27 |
Correct |
2 ms |
1292 KB |
Output is correct |
28 |
Correct |
2 ms |
1292 KB |
Output is correct |
29 |
Correct |
5 ms |
1772 KB |
Output is correct |
30 |
Correct |
2 ms |
1772 KB |
Output is correct |
31 |
Correct |
4 ms |
1772 KB |
Output is correct |
32 |
Correct |
2 ms |
1772 KB |
Output is correct |
33 |
Correct |
2 ms |
1772 KB |
Output is correct |
34 |
Correct |
3 ms |
1772 KB |
Output is correct |
35 |
Correct |
2 ms |
1772 KB |
Output is correct |
36 |
Correct |
2 ms |
1772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1772 KB |
Output is correct |
2 |
Correct |
3 ms |
1772 KB |
Output is correct |
3 |
Correct |
2 ms |
1772 KB |
Output is correct |
4 |
Correct |
2 ms |
1772 KB |
Output is correct |
5 |
Correct |
2 ms |
1772 KB |
Output is correct |
6 |
Correct |
3 ms |
1772 KB |
Output is correct |
7 |
Correct |
2 ms |
1772 KB |
Output is correct |
8 |
Correct |
2 ms |
1772 KB |
Output is correct |
9 |
Correct |
3 ms |
1772 KB |
Output is correct |
10 |
Correct |
2 ms |
1772 KB |
Output is correct |
11 |
Correct |
2 ms |
1772 KB |
Output is correct |
12 |
Correct |
2 ms |
1772 KB |
Output is correct |
13 |
Correct |
3 ms |
1772 KB |
Output is correct |
14 |
Correct |
2 ms |
1772 KB |
Output is correct |
15 |
Correct |
2 ms |
1772 KB |
Output is correct |
16 |
Correct |
2 ms |
1772 KB |
Output is correct |
17 |
Correct |
2 ms |
1772 KB |
Output is correct |
18 |
Correct |
2 ms |
1772 KB |
Output is correct |
19 |
Correct |
2 ms |
1772 KB |
Output is correct |
20 |
Correct |
2 ms |
1772 KB |
Output is correct |
21 |
Correct |
3 ms |
1772 KB |
Output is correct |
22 |
Correct |
2 ms |
1772 KB |
Output is correct |
23 |
Correct |
2 ms |
1772 KB |
Output is correct |
24 |
Correct |
2 ms |
1772 KB |
Output is correct |
25 |
Correct |
3 ms |
1772 KB |
Output is correct |
26 |
Correct |
3 ms |
1772 KB |
Output is correct |
27 |
Correct |
4 ms |
3052 KB |
Output is correct |
28 |
Correct |
3 ms |
3052 KB |
Output is correct |
29 |
Correct |
4 ms |
3052 KB |
Output is correct |
30 |
Correct |
7 ms |
4588 KB |
Output is correct |
31 |
Correct |
12 ms |
6252 KB |
Output is correct |
32 |
Correct |
10 ms |
6252 KB |
Output is correct |
33 |
Correct |
2 ms |
6252 KB |
Output is correct |
34 |
Correct |
9 ms |
6252 KB |
Output is correct |
35 |
Correct |
8 ms |
6252 KB |
Output is correct |
36 |
Correct |
6 ms |
6252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6252 KB |
Output is correct |
2 |
Correct |
2 ms |
6252 KB |
Output is correct |
3 |
Correct |
2 ms |
6252 KB |
Output is correct |
4 |
Correct |
2 ms |
6252 KB |
Output is correct |
5 |
Correct |
2 ms |
6252 KB |
Output is correct |
6 |
Correct |
2 ms |
6252 KB |
Output is correct |
7 |
Correct |
2 ms |
6252 KB |
Output is correct |
8 |
Correct |
2 ms |
6252 KB |
Output is correct |
9 |
Correct |
3 ms |
6252 KB |
Output is correct |
10 |
Correct |
2 ms |
6252 KB |
Output is correct |
11 |
Correct |
2 ms |
6252 KB |
Output is correct |
12 |
Correct |
2 ms |
6252 KB |
Output is correct |
13 |
Correct |
3 ms |
6252 KB |
Output is correct |
14 |
Correct |
4 ms |
6252 KB |
Output is correct |
15 |
Correct |
3 ms |
6252 KB |
Output is correct |
16 |
Correct |
3 ms |
6252 KB |
Output is correct |
17 |
Correct |
7 ms |
6252 KB |
Output is correct |
18 |
Correct |
13 ms |
6252 KB |
Output is correct |
19 |
Correct |
14 ms |
6252 KB |
Output is correct |
20 |
Correct |
2 ms |
6252 KB |
Output is correct |
21 |
Correct |
9 ms |
6252 KB |
Output is correct |
22 |
Correct |
8 ms |
6252 KB |
Output is correct |
23 |
Correct |
5 ms |
6252 KB |
Output is correct |
24 |
Correct |
12 ms |
6252 KB |
Output is correct |
25 |
Correct |
9 ms |
6252 KB |
Output is correct |
26 |
Correct |
36 ms |
10988 KB |
Output is correct |
27 |
Correct |
130 ms |
29676 KB |
Output is correct |
28 |
Correct |
333 ms |
58860 KB |
Output is correct |
29 |
Correct |
314 ms |
78828 KB |
Output is correct |
30 |
Correct |
2 ms |
78828 KB |
Output is correct |
31 |
Correct |
168 ms |
78828 KB |
Output is correct |
32 |
Correct |
284 ms |
78828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
78828 KB |
Output is correct |
2 |
Correct |
2 ms |
78828 KB |
Output is correct |
3 |
Correct |
2 ms |
78828 KB |
Output is correct |
4 |
Correct |
3 ms |
78828 KB |
Output is correct |
5 |
Correct |
2 ms |
78828 KB |
Output is correct |
6 |
Correct |
3 ms |
78828 KB |
Output is correct |
7 |
Correct |
2 ms |
78828 KB |
Output is correct |
8 |
Correct |
2 ms |
78828 KB |
Output is correct |
9 |
Correct |
3 ms |
78828 KB |
Output is correct |
10 |
Correct |
2 ms |
78828 KB |
Output is correct |
11 |
Correct |
2 ms |
78828 KB |
Output is correct |
12 |
Correct |
2 ms |
78828 KB |
Output is correct |
13 |
Correct |
3 ms |
78828 KB |
Output is correct |
14 |
Correct |
2 ms |
78828 KB |
Output is correct |
15 |
Correct |
2 ms |
78828 KB |
Output is correct |
16 |
Correct |
2 ms |
78828 KB |
Output is correct |
17 |
Correct |
2 ms |
78828 KB |
Output is correct |
18 |
Correct |
2 ms |
78828 KB |
Output is correct |
19 |
Correct |
2 ms |
78828 KB |
Output is correct |
20 |
Correct |
2 ms |
78828 KB |
Output is correct |
21 |
Correct |
2 ms |
78828 KB |
Output is correct |
22 |
Correct |
2 ms |
78828 KB |
Output is correct |
23 |
Correct |
2 ms |
78828 KB |
Output is correct |
24 |
Correct |
2 ms |
78828 KB |
Output is correct |
25 |
Correct |
2 ms |
78828 KB |
Output is correct |
26 |
Correct |
3 ms |
78828 KB |
Output is correct |
27 |
Correct |
2 ms |
78828 KB |
Output is correct |
28 |
Correct |
2 ms |
78828 KB |
Output is correct |
29 |
Correct |
6 ms |
78828 KB |
Output is correct |
30 |
Correct |
2 ms |
78828 KB |
Output is correct |
31 |
Correct |
3 ms |
78828 KB |
Output is correct |
32 |
Correct |
2 ms |
78828 KB |
Output is correct |
33 |
Correct |
2 ms |
78828 KB |
Output is correct |
34 |
Correct |
2 ms |
78828 KB |
Output is correct |
35 |
Correct |
2 ms |
78828 KB |
Output is correct |
36 |
Correct |
2 ms |
78828 KB |
Output is correct |
37 |
Correct |
4 ms |
78828 KB |
Output is correct |
38 |
Correct |
3 ms |
78828 KB |
Output is correct |
39 |
Correct |
3 ms |
78828 KB |
Output is correct |
40 |
Correct |
6 ms |
78828 KB |
Output is correct |
41 |
Correct |
12 ms |
78828 KB |
Output is correct |
42 |
Correct |
10 ms |
78828 KB |
Output is correct |
43 |
Correct |
2 ms |
78828 KB |
Output is correct |
44 |
Correct |
9 ms |
78828 KB |
Output is correct |
45 |
Correct |
9 ms |
78828 KB |
Output is correct |
46 |
Correct |
6 ms |
78828 KB |
Output is correct |
47 |
Correct |
12 ms |
78828 KB |
Output is correct |
48 |
Correct |
9 ms |
78828 KB |
Output is correct |
49 |
Correct |
36 ms |
78828 KB |
Output is correct |
50 |
Correct |
131 ms |
78828 KB |
Output is correct |
51 |
Correct |
308 ms |
78828 KB |
Output is correct |
52 |
Correct |
302 ms |
78980 KB |
Output is correct |
53 |
Correct |
3 ms |
78980 KB |
Output is correct |
54 |
Correct |
187 ms |
78980 KB |
Output is correct |
55 |
Correct |
292 ms |
78980 KB |
Output is correct |
56 |
Runtime error |
5 ms |
78980 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
57 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
78980 KB |
Output is correct |
2 |
Correct |
2 ms |
78980 KB |
Output is correct |
3 |
Correct |
2 ms |
78980 KB |
Output is correct |
4 |
Correct |
2 ms |
78980 KB |
Output is correct |
5 |
Correct |
2 ms |
78980 KB |
Output is correct |
6 |
Correct |
2 ms |
78980 KB |
Output is correct |
7 |
Correct |
2 ms |
78980 KB |
Output is correct |
8 |
Correct |
2 ms |
78980 KB |
Output is correct |
9 |
Correct |
2 ms |
78980 KB |
Output is correct |
10 |
Correct |
2 ms |
78980 KB |
Output is correct |
11 |
Correct |
2 ms |
78980 KB |
Output is correct |
12 |
Correct |
2 ms |
78980 KB |
Output is correct |
13 |
Correct |
3 ms |
78980 KB |
Output is correct |
14 |
Correct |
2 ms |
78980 KB |
Output is correct |
15 |
Correct |
2 ms |
78980 KB |
Output is correct |
16 |
Correct |
5 ms |
78980 KB |
Output is correct |
17 |
Correct |
2 ms |
78980 KB |
Output is correct |
18 |
Correct |
3 ms |
78980 KB |
Output is correct |
19 |
Correct |
2 ms |
78980 KB |
Output is correct |
20 |
Correct |
2 ms |
78980 KB |
Output is correct |
21 |
Correct |
2 ms |
78980 KB |
Output is correct |
22 |
Correct |
2 ms |
78980 KB |
Output is correct |
23 |
Correct |
2 ms |
78980 KB |
Output is correct |
24 |
Correct |
4 ms |
78980 KB |
Output is correct |
25 |
Correct |
3 ms |
78980 KB |
Output is correct |
26 |
Correct |
3 ms |
78980 KB |
Output is correct |
27 |
Correct |
7 ms |
78980 KB |
Output is correct |
28 |
Correct |
13 ms |
78980 KB |
Output is correct |
29 |
Correct |
10 ms |
78980 KB |
Output is correct |
30 |
Correct |
2 ms |
78980 KB |
Output is correct |
31 |
Correct |
9 ms |
78980 KB |
Output is correct |
32 |
Correct |
9 ms |
78980 KB |
Output is correct |
33 |
Correct |
6 ms |
78980 KB |
Output is correct |
34 |
Correct |
11 ms |
78980 KB |
Output is correct |
35 |
Correct |
9 ms |
78980 KB |
Output is correct |
36 |
Correct |
39 ms |
78980 KB |
Output is correct |
37 |
Correct |
128 ms |
78980 KB |
Output is correct |
38 |
Correct |
306 ms |
78980 KB |
Output is correct |
39 |
Correct |
297 ms |
79684 KB |
Output is correct |
40 |
Correct |
2 ms |
79684 KB |
Output is correct |
41 |
Correct |
164 ms |
79684 KB |
Output is correct |
42 |
Correct |
286 ms |
79684 KB |
Output is correct |
43 |
Runtime error |
6 ms |
79684 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
44 |
Halted |
0 ms |
0 KB |
- |