#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 1e2 + 2;
const int maxbit = 512;
bool dp[maxn][maxn][maxbit];
int pref [maxn];
int arr[maxn];
vector <int> v[maxbit][maxbit]; // v[x][y] -> all integer z that x | z = y
int main() {
int n,a,b;
cin >> n >> a >> b;
for (int i = 0; i < maxbit; i++){
for (int j = 0; j < maxbit; j++){
v[i][i | j].push_back(j);
}
}
for (int i = 1; i <= n; i++){
cin >> arr[i];
pref[i] = pref[i-1] + arr[i];
dp[i][1][pref[i]] = 1;
}
for (int k = 2; k <= b; k++){
for (int r = 1; r <= n; r++){
for (int l = 1; l <= r; l++){
for (int ans = 0; ans < maxbit; ans++){
for (int z: v[pref[r] - pref[l - 1]][ans]) dp[r][k][ans] |= dp[l-1][k-1][z];
// for (int to = 0; to <= ans; to++){
}
}
}
}
int rs = 1e9;
for (int i = a; i <= b; i++){
for (int j = 0; j < maxbit; j++)
rs = min(rs, dp[n][i][j] ? j: (int) 1e9);
}
cout << rs << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7764 KB |
Output is correct |
2 |
Correct |
8 ms |
7856 KB |
Output is correct |
3 |
Correct |
8 ms |
7732 KB |
Output is correct |
4 |
Correct |
9 ms |
7764 KB |
Output is correct |
5 |
Correct |
8 ms |
7768 KB |
Output is correct |
6 |
Correct |
9 ms |
7892 KB |
Output is correct |
7 |
Correct |
9 ms |
7900 KB |
Output is correct |
8 |
Correct |
8 ms |
7892 KB |
Output is correct |
9 |
Correct |
8 ms |
7892 KB |
Output is correct |
10 |
Correct |
10 ms |
7900 KB |
Output is correct |
11 |
Correct |
8 ms |
7892 KB |
Output is correct |
12 |
Correct |
8 ms |
7892 KB |
Output is correct |
13 |
Correct |
13 ms |
8000 KB |
Output is correct |
14 |
Correct |
8 ms |
7764 KB |
Output is correct |
15 |
Correct |
8 ms |
7764 KB |
Output is correct |
16 |
Correct |
8 ms |
7764 KB |
Output is correct |
17 |
Correct |
8 ms |
7864 KB |
Output is correct |
18 |
Correct |
7 ms |
7864 KB |
Output is correct |
19 |
Correct |
11 ms |
7892 KB |
Output is correct |
20 |
Correct |
8 ms |
7892 KB |
Output is correct |
21 |
Correct |
9 ms |
7892 KB |
Output is correct |
22 |
Correct |
9 ms |
7892 KB |
Output is correct |
23 |
Correct |
10 ms |
7892 KB |
Output is correct |
24 |
Correct |
9 ms |
7824 KB |
Output is correct |
25 |
Correct |
9 ms |
7964 KB |
Output is correct |
26 |
Correct |
11 ms |
7956 KB |
Output is correct |
27 |
Runtime error |
14 ms |
15620 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7764 KB |
Output is correct |
2 |
Correct |
9 ms |
7764 KB |
Output is correct |
3 |
Correct |
8 ms |
7764 KB |
Output is correct |
4 |
Correct |
9 ms |
7864 KB |
Output is correct |
5 |
Correct |
9 ms |
7832 KB |
Output is correct |
6 |
Correct |
9 ms |
7936 KB |
Output is correct |
7 |
Correct |
8 ms |
7932 KB |
Output is correct |
8 |
Correct |
8 ms |
7892 KB |
Output is correct |
9 |
Correct |
12 ms |
7900 KB |
Output is correct |
10 |
Correct |
9 ms |
7892 KB |
Output is correct |
11 |
Correct |
10 ms |
7892 KB |
Output is correct |
12 |
Correct |
8 ms |
7892 KB |
Output is correct |
13 |
Correct |
13 ms |
8008 KB |
Output is correct |
14 |
Correct |
7 ms |
7764 KB |
Output is correct |
15 |
Correct |
10 ms |
7856 KB |
Output is correct |
16 |
Correct |
8 ms |
7764 KB |
Output is correct |
17 |
Correct |
10 ms |
7804 KB |
Output is correct |
18 |
Correct |
8 ms |
7764 KB |
Output is correct |
19 |
Correct |
9 ms |
7892 KB |
Output is correct |
20 |
Correct |
8 ms |
7920 KB |
Output is correct |
21 |
Correct |
9 ms |
7952 KB |
Output is correct |
22 |
Correct |
10 ms |
7892 KB |
Output is correct |
23 |
Correct |
10 ms |
7876 KB |
Output is correct |
24 |
Correct |
8 ms |
7892 KB |
Output is correct |
25 |
Correct |
9 ms |
7892 KB |
Output is correct |
26 |
Correct |
11 ms |
7956 KB |
Output is correct |
27 |
Correct |
18 ms |
8020 KB |
Output is correct |
28 |
Correct |
11 ms |
7980 KB |
Output is correct |
29 |
Correct |
11 ms |
8068 KB |
Output is correct |
30 |
Correct |
24 ms |
8272 KB |
Output is correct |
31 |
Correct |
34 ms |
8404 KB |
Output is correct |
32 |
Correct |
33 ms |
8384 KB |
Output is correct |
33 |
Correct |
9 ms |
7996 KB |
Output is correct |
34 |
Correct |
39 ms |
8440 KB |
Output is correct |
35 |
Correct |
30 ms |
8392 KB |
Output is correct |
36 |
Correct |
20 ms |
8244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
7780 KB |
Output is correct |
2 |
Correct |
10 ms |
7764 KB |
Output is correct |
3 |
Correct |
10 ms |
7892 KB |
Output is correct |
4 |
Correct |
10 ms |
7764 KB |
Output is correct |
5 |
Correct |
8 ms |
7764 KB |
Output is correct |
6 |
Correct |
13 ms |
7892 KB |
Output is correct |
7 |
Correct |
8 ms |
7892 KB |
Output is correct |
8 |
Correct |
11 ms |
7988 KB |
Output is correct |
9 |
Correct |
10 ms |
7892 KB |
Output is correct |
10 |
Correct |
8 ms |
7924 KB |
Output is correct |
11 |
Correct |
10 ms |
7792 KB |
Output is correct |
12 |
Correct |
9 ms |
7920 KB |
Output is correct |
13 |
Correct |
12 ms |
8020 KB |
Output is correct |
14 |
Correct |
15 ms |
8016 KB |
Output is correct |
15 |
Correct |
12 ms |
7960 KB |
Output is correct |
16 |
Correct |
13 ms |
8020 KB |
Output is correct |
17 |
Correct |
28 ms |
8300 KB |
Output is correct |
18 |
Correct |
39 ms |
8428 KB |
Output is correct |
19 |
Correct |
39 ms |
8480 KB |
Output is correct |
20 |
Correct |
11 ms |
7996 KB |
Output is correct |
21 |
Correct |
40 ms |
8396 KB |
Output is correct |
22 |
Correct |
39 ms |
8448 KB |
Output is correct |
23 |
Correct |
25 ms |
8268 KB |
Output is correct |
24 |
Correct |
52 ms |
8456 KB |
Output is correct |
25 |
Runtime error |
22 ms |
16272 KB |
Execution killed with signal 11 |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
7776 KB |
Output is correct |
2 |
Correct |
8 ms |
7764 KB |
Output is correct |
3 |
Correct |
8 ms |
7736 KB |
Output is correct |
4 |
Correct |
8 ms |
7764 KB |
Output is correct |
5 |
Correct |
10 ms |
7764 KB |
Output is correct |
6 |
Correct |
10 ms |
7972 KB |
Output is correct |
7 |
Correct |
9 ms |
7820 KB |
Output is correct |
8 |
Correct |
9 ms |
7892 KB |
Output is correct |
9 |
Correct |
9 ms |
7844 KB |
Output is correct |
10 |
Correct |
9 ms |
7892 KB |
Output is correct |
11 |
Correct |
8 ms |
7804 KB |
Output is correct |
12 |
Correct |
8 ms |
7924 KB |
Output is correct |
13 |
Correct |
11 ms |
7972 KB |
Output is correct |
14 |
Correct |
10 ms |
7764 KB |
Output is correct |
15 |
Correct |
9 ms |
7764 KB |
Output is correct |
16 |
Correct |
11 ms |
7812 KB |
Output is correct |
17 |
Correct |
9 ms |
7776 KB |
Output is correct |
18 |
Correct |
9 ms |
7904 KB |
Output is correct |
19 |
Correct |
10 ms |
7904 KB |
Output is correct |
20 |
Correct |
9 ms |
7904 KB |
Output is correct |
21 |
Correct |
10 ms |
7908 KB |
Output is correct |
22 |
Correct |
9 ms |
7996 KB |
Output is correct |
23 |
Correct |
13 ms |
7944 KB |
Output is correct |
24 |
Correct |
9 ms |
7904 KB |
Output is correct |
25 |
Correct |
9 ms |
7904 KB |
Output is correct |
26 |
Correct |
11 ms |
8044 KB |
Output is correct |
27 |
Runtime error |
15 ms |
15584 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7772 KB |
Output is correct |
2 |
Correct |
8 ms |
7772 KB |
Output is correct |
3 |
Correct |
8 ms |
7776 KB |
Output is correct |
4 |
Correct |
8 ms |
7768 KB |
Output is correct |
5 |
Correct |
8 ms |
7772 KB |
Output is correct |
6 |
Correct |
12 ms |
7900 KB |
Output is correct |
7 |
Correct |
12 ms |
7892 KB |
Output is correct |
8 |
Correct |
10 ms |
7884 KB |
Output is correct |
9 |
Correct |
10 ms |
7892 KB |
Output is correct |
10 |
Correct |
9 ms |
7900 KB |
Output is correct |
11 |
Correct |
12 ms |
7808 KB |
Output is correct |
12 |
Correct |
9 ms |
7892 KB |
Output is correct |
13 |
Correct |
13 ms |
8020 KB |
Output is correct |
14 |
Runtime error |
15 ms |
15644 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |