#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 1e2 + 2;
const int maxbit = 200;
int64 dp[maxn][maxn][maxbit];
int64 pref [maxn];
int64 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 < maxbit; 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";
// }
int64 rs = 1e15;
for (int i = a; i <= b; i++){
for (int j = 0; j < maxbit; j++)
rs = min(rs, dp[n][i][j] ? j: (int64) 1e15);
}
cout << rs << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
51 ms |
600 KB |
Output is correct |
7 |
Correct |
10 ms |
452 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
13 ms |
440 KB |
Output is correct |
10 |
Incorrect |
13 ms |
468 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
50 ms |
704 KB |
Output is correct |
7 |
Correct |
10 ms |
424 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
14 ms |
420 KB |
Output is correct |
10 |
Incorrect |
13 ms |
464 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
57 ms |
640 KB |
Output is correct |
7 |
Correct |
9 ms |
340 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
13 ms |
468 KB |
Output is correct |
10 |
Incorrect |
13 ms |
468 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
52 ms |
772 KB |
Output is correct |
7 |
Correct |
12 ms |
540 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
13 ms |
468 KB |
Output is correct |
10 |
Incorrect |
13 ms |
436 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
4 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
51 ms |
668 KB |
Output is correct |
7 |
Correct |
10 ms |
416 KB |
Output is correct |
8 |
Correct |
13 ms |
468 KB |
Output is correct |
9 |
Correct |
15 ms |
436 KB |
Output is correct |
10 |
Incorrect |
13 ms |
472 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |