#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 2e3 + 2;
int64 dp[maxn][maxn][32];
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 < 32; ans++){
for (int to = 0; to < 32; 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 < 32; j++)
rs = min(rs, dp[n][i][j] ? j: 50 * 1ll);
}
cout << rs << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |