#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int maxn = 1e2 + 2;
int64 dp[maxn][maxn];
int64 pref [maxn][maxn];
int64 arr[maxn];
int main() {
for (int i = 0; i < maxn; i++) for (int j = 0; j < maxn; j++) dp[i][j] = 1e18;
int n,a,b;
cin >> n >> a >> b;
for (int i = 1; i <= n; i++){
cin >> arr[i];
}
for (int i = 1; i <= n; i++){
pref[i][i] = arr[i];
for (int j = i + 1; j <= n; j++){
pref[i][j] = pref[i][j-1] ^ arr[j];
}
}
for (int i = 1; i <= n; i++) dp[i][1] = pref[1][i];
for (int k = 2; k <= b; k++){
for (int r = 1; r <= n; r++){
for (int l = 1; l <= r; l++){
dp[r][k] = min(dp[r][k], dp[l-1][k-1] + pref[l][r]);
}
}
}
int64 rs = 1e18;
for (int i = a; i <= b; i++){
rs = min(rs, dp[n][i]);
}
cout << rs << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |