#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(x > gr)return 1e15;
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 |
9308 KB |
Output is correct |
2 |
Correct |
2 ms |
9304 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 |
9304 KB |
Output is correct |
7 |
Correct |
2 ms |
9308 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 |
3 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 |
9356 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 |
2 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 |
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 |
9304 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 |
2 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 |
9560 KB |
Output is correct |
6 |
Correct |
2 ms |
9352 KB |
Output is correct |
7 |
Correct |
2 ms |
9308 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 |
9516 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 |
9388 KB |
Output is correct |
15 |
Correct |
3 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 |
3 ms |
9308 KB |
Output is correct |
19 |
Correct |
3 ms |
9308 KB |
Output is correct |
20 |
Correct |
2 ms |
9276 KB |
Output is correct |
21 |
Correct |
3 ms |
9308 KB |
Output is correct |
22 |
Correct |
3 ms |
9308 KB |
Output is correct |
23 |
Correct |
2 ms |
9308 KB |
Output is correct |
24 |
Correct |
3 ms |
9308 KB |
Output is correct |
25 |
Correct |
2 ms |
9308 KB |
Output is correct |
26 |
Correct |
5 ms |
9308 KB |
Output is correct |
27 |
Correct |
21 ms |
9308 KB |
Output is correct |
28 |
Correct |
59 ms |
9308 KB |
Output is correct |
29 |
Correct |
68 ms |
9308 KB |
Output is correct |
30 |
Correct |
2 ms |
9304 KB |
Output is correct |
31 |
Correct |
20 ms |
9308 KB |
Output is correct |
32 |
Correct |
38 ms |
9516 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 |
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 |
3 ms |
9712 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 |
9320 KB |
Output is correct |
15 |
Correct |
2 ms |
9320 KB |
Output is correct |
16 |
Correct |
2 ms |
9368 KB |
Output is correct |
17 |
Correct |
2 ms |
9320 KB |
Output is correct |
18 |
Correct |
2 ms |
9304 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 |
2 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 |
9344 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 |
9360 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 |
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 |
Correct |
2 ms |
9308 KB |
Output is correct |
22 |
Correct |
2 ms |
9308 KB |
Output is correct |
23 |
Correct |
3 ms |
9308 KB |
Output is correct |
24 |
Correct |
2 ms |
9304 KB |
Output is correct |
25 |
Correct |
2 ms |
9308 KB |
Output is correct |
26 |
Correct |
2 ms |
9320 KB |
Output is correct |
27 |
Correct |
2 ms |
9308 KB |
Output is correct |
28 |
Correct |
3 ms |
9308 KB |
Output is correct |
29 |
Correct |
3 ms |
9308 KB |
Output is correct |
30 |
Correct |
2 ms |
9304 KB |
Output is correct |
31 |
Correct |
3 ms |
9304 KB |
Output is correct |
32 |
Correct |
2 ms |
9308 KB |
Output is correct |
33 |
Correct |
2 ms |
9560 KB |
Output is correct |
34 |
Correct |
3 ms |
9560 KB |
Output is correct |
35 |
Correct |
2 ms |
9308 KB |
Output is correct |
36 |
Correct |
5 ms |
9308 KB |
Output is correct |
37 |
Correct |
20 ms |
9304 KB |
Output is correct |
38 |
Correct |
56 ms |
9308 KB |
Output is correct |
39 |
Correct |
56 ms |
9304 KB |
Output is correct |
40 |
Correct |
2 ms |
9312 KB |
Output is correct |
41 |
Correct |
19 ms |
9308 KB |
Output is correct |
42 |
Correct |
37 ms |
9304 KB |
Output is correct |
43 |
Incorrect |
3 ms |
9308 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |