#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 1e2 + 2;
const int maxbit = 300;
bool dp[maxn][maxn][maxbit];
int pref [maxn];
int arr[maxn];
int main() {
int n,a,b;
cin >> n >> a >> b;
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 to = 0; to <= ans; to++){
if (((to | (pref[r] - pref[l - 1])) == ans)) dp[r][k][ans] |= dp[l-1][k-1][to];
}
}
}
}
}
// for (int i = 1; i <= b; i++){
// for (int j = 1; j <= n; j++){
// cout << setw(10) << dp[j][i] << " ";
// }
// cout << "\n";
// }
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 |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
62 ms |
392 KB |
Output is correct |
7 |
Correct |
11 ms |
340 KB |
Output is correct |
8 |
Correct |
27 ms |
388 KB |
Output is correct |
9 |
Correct |
17 ms |
340 KB |
Output is correct |
10 |
Correct |
15 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
15 ms |
340 KB |
Output is correct |
13 |
Correct |
115 ms |
396 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
7 ms |
340 KB |
Output is correct |
19 |
Correct |
75 ms |
392 KB |
Output is correct |
20 |
Correct |
11 ms |
340 KB |
Output is correct |
21 |
Correct |
61 ms |
524 KB |
Output is correct |
22 |
Correct |
44 ms |
404 KB |
Output is correct |
23 |
Correct |
45 ms |
404 KB |
Output is correct |
24 |
Correct |
11 ms |
400 KB |
Output is correct |
25 |
Correct |
46 ms |
340 KB |
Output is correct |
26 |
Correct |
89 ms |
404 KB |
Output is correct |
27 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
280 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
62 ms |
340 KB |
Output is correct |
7 |
Correct |
12 ms |
388 KB |
Output is correct |
8 |
Correct |
15 ms |
340 KB |
Output is correct |
9 |
Correct |
15 ms |
392 KB |
Output is correct |
10 |
Correct |
15 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
15 ms |
404 KB |
Output is correct |
13 |
Correct |
114 ms |
528 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
8 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
340 KB |
Output is correct |
19 |
Correct |
74 ms |
380 KB |
Output is correct |
20 |
Correct |
11 ms |
384 KB |
Output is correct |
21 |
Correct |
45 ms |
408 KB |
Output is correct |
22 |
Correct |
52 ms |
408 KB |
Output is correct |
23 |
Correct |
47 ms |
388 KB |
Output is correct |
24 |
Correct |
9 ms |
340 KB |
Output is correct |
25 |
Correct |
45 ms |
404 KB |
Output is correct |
26 |
Correct |
93 ms |
408 KB |
Output is correct |
27 |
Correct |
154 ms |
412 KB |
Output is correct |
28 |
Correct |
105 ms |
428 KB |
Output is correct |
29 |
Correct |
104 ms |
468 KB |
Output is correct |
30 |
Correct |
639 ms |
620 KB |
Output is correct |
31 |
Incorrect |
905 ms |
768 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
71 ms |
340 KB |
Output is correct |
7 |
Correct |
15 ms |
388 KB |
Output is correct |
8 |
Correct |
16 ms |
400 KB |
Output is correct |
9 |
Correct |
17 ms |
396 KB |
Output is correct |
10 |
Correct |
20 ms |
400 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
17 ms |
408 KB |
Output is correct |
13 |
Correct |
130 ms |
400 KB |
Output is correct |
14 |
Correct |
196 ms |
532 KB |
Output is correct |
15 |
Correct |
114 ms |
420 KB |
Output is correct |
16 |
Correct |
128 ms |
468 KB |
Output is correct |
17 |
Correct |
601 ms |
644 KB |
Output is correct |
18 |
Incorrect |
955 ms |
768 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
58 ms |
384 KB |
Output is correct |
7 |
Correct |
11 ms |
396 KB |
Output is correct |
8 |
Correct |
16 ms |
400 KB |
Output is correct |
9 |
Correct |
16 ms |
340 KB |
Output is correct |
10 |
Correct |
16 ms |
400 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
19 ms |
400 KB |
Output is correct |
13 |
Correct |
191 ms |
416 KB |
Output is correct |
14 |
Correct |
3 ms |
212 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
6 ms |
348 KB |
Output is correct |
19 |
Correct |
75 ms |
404 KB |
Output is correct |
20 |
Correct |
17 ms |
348 KB |
Output is correct |
21 |
Correct |
54 ms |
404 KB |
Output is correct |
22 |
Correct |
46 ms |
412 KB |
Output is correct |
23 |
Correct |
63 ms |
396 KB |
Output is correct |
24 |
Correct |
11 ms |
396 KB |
Output is correct |
25 |
Correct |
46 ms |
396 KB |
Output is correct |
26 |
Correct |
89 ms |
412 KB |
Output is correct |
27 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
5 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
220 KB |
Output is correct |
4 |
Correct |
2 ms |
220 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
86 ms |
392 KB |
Output is correct |
7 |
Correct |
15 ms |
408 KB |
Output is correct |
8 |
Correct |
16 ms |
404 KB |
Output is correct |
9 |
Correct |
15 ms |
392 KB |
Output is correct |
10 |
Correct |
18 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
352 KB |
Output is correct |
12 |
Correct |
15 ms |
340 KB |
Output is correct |
13 |
Correct |
136 ms |
460 KB |
Output is correct |
14 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |