#include<bits/stdc++.h>
using namespace std;
const int mxN = 105;
long long dp[mxN][mxN][mxN];
int a, b, n;
vector<int>v;
long long rec(int indx, int x, int gr){
long long res = 1e15, sum = 0;
if(indx == n && x == gr)return 0;
if(indx == n)return 1e15;
if(dp[indx][x][gr] != -1)return dp[indx][x][gr];
for(int i = indx;i < n;++i){
sum += v[i];
res = min(res, sum | rec(i + 1, x + 1, gr));
}
return dp[indx][x][gr] = res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> a >> b;
v.resize(n);
for(int i = 0;i < mxN;++i){
for(int j = 0;j < mxN;++j){
for(int k = 0;k < mxN;++k){
dp[i][j][k] = -1;
}
}
}
for(int i = 0;i < n;++i){
cin >> v[i];
}
long long res = 1e18;
for(int i = a;i <= b;++i){
res = min(res, rec(0, 0, i));
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9304 KB |
Output is correct |
2 |
Correct |
2 ms |
9308 KB |
Output is correct |
3 |
Correct |
2 ms |
9308 KB |
Output is correct |
4 |
Correct |
2 ms |
9308 KB |
Output is correct |
5 |
Correct |
2 ms |
9308 KB |
Output is correct |
6 |
Correct |
2 ms |
9308 KB |
Output is correct |
7 |
Correct |
2 ms |
9308 KB |
Output is correct |
8 |
Correct |
2 ms |
9308 KB |
Output is correct |
9 |
Correct |
3 ms |
9308 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
3 ms |
9308 KB |
Output is correct |
12 |
Correct |
3 ms |
9308 KB |
Output is correct |
13 |
Correct |
2 ms |
9304 KB |
Output is correct |
14 |
Correct |
2 ms |
9304 KB |
Output is correct |
15 |
Correct |
2 ms |
9308 KB |
Output is correct |
16 |
Correct |
2 ms |
9308 KB |
Output is correct |
17 |
Correct |
3 ms |
9308 KB |
Output is correct |
18 |
Correct |
2 ms |
9308 KB |
Output is correct |
19 |
Correct |
2 ms |
9352 KB |
Output is correct |
20 |
Correct |
2 ms |
9308 KB |
Output is correct |
21 |
Incorrect |
3 ms |
9308 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9308 KB |
Output is correct |
2 |
Correct |
2 ms |
9308 KB |
Output is correct |
3 |
Correct |
2 ms |
9308 KB |
Output is correct |
4 |
Correct |
2 ms |
9308 KB |
Output is correct |
5 |
Correct |
2 ms |
9308 KB |
Output is correct |
6 |
Correct |
2 ms |
9308 KB |
Output is correct |
7 |
Correct |
2 ms |
9308 KB |
Output is correct |
8 |
Correct |
2 ms |
9304 KB |
Output is correct |
9 |
Correct |
2 ms |
9308 KB |
Output is correct |
10 |
Correct |
2 ms |
9356 KB |
Output is correct |
11 |
Correct |
2 ms |
9308 KB |
Output is correct |
12 |
Correct |
2 ms |
9308 KB |
Output is correct |
13 |
Correct |
2 ms |
9308 KB |
Output is correct |
14 |
Correct |
2 ms |
9356 KB |
Output is correct |
15 |
Correct |
2 ms |
9308 KB |
Output is correct |
16 |
Correct |
2 ms |
9560 KB |
Output is correct |
17 |
Correct |
2 ms |
9308 KB |
Output is correct |
18 |
Correct |
2 ms |
9308 KB |
Output is correct |
19 |
Correct |
2 ms |
9308 KB |
Output is correct |
20 |
Correct |
2 ms |
9308 KB |
Output is correct |
21 |
Incorrect |
3 ms |
9304 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9304 KB |
Output is correct |
2 |
Correct |
2 ms |
9308 KB |
Output is correct |
3 |
Correct |
2 ms |
9308 KB |
Output is correct |
4 |
Correct |
2 ms |
9308 KB |
Output is correct |
5 |
Correct |
2 ms |
9308 KB |
Output is correct |
6 |
Correct |
2 ms |
9308 KB |
Output is correct |
7 |
Correct |
2 ms |
9308 KB |
Output is correct |
8 |
Correct |
2 ms |
9304 KB |
Output is correct |
9 |
Correct |
2 ms |
9304 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
2 ms |
9308 KB |
Output is correct |
12 |
Correct |
2 ms |
9308 KB |
Output is correct |
13 |
Correct |
2 ms |
9308 KB |
Output is correct |
14 |
Correct |
2 ms |
9308 KB |
Output is correct |
15 |
Correct |
2 ms |
9308 KB |
Output is correct |
16 |
Correct |
2 ms |
9308 KB |
Output is correct |
17 |
Correct |
3 ms |
9308 KB |
Output is correct |
18 |
Correct |
4 ms |
9308 KB |
Output is correct |
19 |
Correct |
4 ms |
9308 KB |
Output is correct |
20 |
Correct |
3 ms |
9308 KB |
Output is correct |
21 |
Correct |
4 ms |
9520 KB |
Output is correct |
22 |
Correct |
4 ms |
9308 KB |
Output is correct |
23 |
Correct |
4 ms |
9584 KB |
Output is correct |
24 |
Correct |
4 ms |
9304 KB |
Output is correct |
25 |
Correct |
4 ms |
9308 KB |
Output is correct |
26 |
Correct |
10 ms |
9308 KB |
Output is correct |
27 |
Correct |
31 ms |
9308 KB |
Output is correct |
28 |
Correct |
73 ms |
9308 KB |
Output is correct |
29 |
Correct |
72 ms |
9308 KB |
Output is correct |
30 |
Correct |
3 ms |
9304 KB |
Output is correct |
31 |
Correct |
43 ms |
9552 KB |
Output is correct |
32 |
Correct |
54 ms |
9560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
9308 KB |
Output is correct |
2 |
Correct |
2 ms |
9308 KB |
Output is correct |
3 |
Correct |
2 ms |
9360 KB |
Output is correct |
4 |
Correct |
2 ms |
9308 KB |
Output is correct |
5 |
Correct |
2 ms |
9308 KB |
Output is correct |
6 |
Correct |
2 ms |
9456 KB |
Output is correct |
7 |
Correct |
2 ms |
9304 KB |
Output is correct |
8 |
Correct |
2 ms |
9308 KB |
Output is correct |
9 |
Correct |
2 ms |
9308 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
2 ms |
9308 KB |
Output is correct |
12 |
Correct |
2 ms |
9308 KB |
Output is correct |
13 |
Correct |
2 ms |
9308 KB |
Output is correct |
14 |
Correct |
2 ms |
9308 KB |
Output is correct |
15 |
Correct |
2 ms |
9308 KB |
Output is correct |
16 |
Correct |
2 ms |
9308 KB |
Output is correct |
17 |
Correct |
2 ms |
9308 KB |
Output is correct |
18 |
Correct |
2 ms |
9308 KB |
Output is correct |
19 |
Correct |
2 ms |
9308 KB |
Output is correct |
20 |
Correct |
2 ms |
9308 KB |
Output is correct |
21 |
Incorrect |
2 ms |
9308 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9308 KB |
Output is correct |
2 |
Correct |
2 ms |
9308 KB |
Output is correct |
3 |
Correct |
2 ms |
9308 KB |
Output is correct |
4 |
Correct |
2 ms |
9560 KB |
Output is correct |
5 |
Correct |
2 ms |
9304 KB |
Output is correct |
6 |
Correct |
2 ms |
9308 KB |
Output is correct |
7 |
Correct |
3 ms |
9308 KB |
Output is correct |
8 |
Correct |
2 ms |
9308 KB |
Output is correct |
9 |
Correct |
3 ms |
9308 KB |
Output is correct |
10 |
Correct |
2 ms |
9308 KB |
Output is correct |
11 |
Correct |
2 ms |
9304 KB |
Output is correct |
12 |
Correct |
2 ms |
9308 KB |
Output is correct |
13 |
Correct |
2 ms |
9308 KB |
Output is correct |
14 |
Correct |
2 ms |
9308 KB |
Output is correct |
15 |
Correct |
2 ms |
9308 KB |
Output is correct |
16 |
Correct |
3 ms |
9304 KB |
Output is correct |
17 |
Correct |
2 ms |
9304 KB |
Output is correct |
18 |
Correct |
2 ms |
9308 KB |
Output is correct |
19 |
Correct |
2 ms |
9308 KB |
Output is correct |
20 |
Correct |
2 ms |
9308 KB |
Output is correct |
21 |
Correct |
2 ms |
9308 KB |
Output is correct |
22 |
Correct |
3 ms |
9308 KB |
Output is correct |
23 |
Correct |
2 ms |
9304 KB |
Output is correct |
24 |
Correct |
2 ms |
9308 KB |
Output is correct |
25 |
Correct |
2 ms |
9308 KB |
Output is correct |
26 |
Correct |
2 ms |
9308 KB |
Output is correct |
27 |
Correct |
3 ms |
9360 KB |
Output is correct |
28 |
Correct |
4 ms |
9424 KB |
Output is correct |
29 |
Correct |
4 ms |
9308 KB |
Output is correct |
30 |
Correct |
3 ms |
9308 KB |
Output is correct |
31 |
Correct |
4 ms |
9308 KB |
Output is correct |
32 |
Correct |
4 ms |
9308 KB |
Output is correct |
33 |
Correct |
3 ms |
9360 KB |
Output is correct |
34 |
Correct |
5 ms |
9308 KB |
Output is correct |
35 |
Correct |
4 ms |
9304 KB |
Output is correct |
36 |
Correct |
10 ms |
9308 KB |
Output is correct |
37 |
Correct |
31 ms |
9516 KB |
Output is correct |
38 |
Correct |
74 ms |
9344 KB |
Output is correct |
39 |
Correct |
74 ms |
9504 KB |
Output is correct |
40 |
Correct |
3 ms |
9308 KB |
Output is correct |
41 |
Correct |
36 ms |
9496 KB |
Output is correct |
42 |
Correct |
54 ms |
9308 KB |
Output is correct |
43 |
Incorrect |
4 ms |
9308 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |