#include <bits/stdc++.h>
using namespace std;
const int N = (int) 103;
const long long inf = (long long) 4e18;
int n, a, b, y[N];
long long dp[N][N][N], S[N];
long long sol(int i, int j, int stage) {
if (i == n) {
if (stage < a || stage > b) {
return inf;
}
return S[i - 1] - (j ? S[j - 1] : 0);
}
long long& ret = dp[i][j][stage];
if (ret != -1) {
return ret;
}
ret = sol(i + 1, j, stage);
if (stage + 1 <= b && i + 1 < n) {
ret = min(ret, (S[i] - (j ? S[j - 1] : 0)) | sol(i + 1, i + 1, stage + 1));
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
cin >> y[i];
}
S[0] = y[0];
for (int i = 1; i < n; i++) {
S[i] += y[i] + S[i - 1];
}
memset(dp, -1, sizeof dp);
cout << sol(0, 0, 1) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8780 KB |
Output is correct |
2 |
Correct |
4 ms |
8780 KB |
Output is correct |
3 |
Correct |
5 ms |
8788 KB |
Output is correct |
4 |
Correct |
5 ms |
8780 KB |
Output is correct |
5 |
Correct |
5 ms |
8780 KB |
Output is correct |
6 |
Correct |
5 ms |
8780 KB |
Output is correct |
7 |
Correct |
4 ms |
8780 KB |
Output is correct |
8 |
Correct |
4 ms |
8780 KB |
Output is correct |
9 |
Correct |
4 ms |
8780 KB |
Output is correct |
10 |
Correct |
5 ms |
8780 KB |
Output is correct |
11 |
Correct |
4 ms |
8784 KB |
Output is correct |
12 |
Correct |
5 ms |
8780 KB |
Output is correct |
13 |
Correct |
5 ms |
8780 KB |
Output is correct |
14 |
Correct |
4 ms |
8780 KB |
Output is correct |
15 |
Correct |
5 ms |
8768 KB |
Output is correct |
16 |
Correct |
5 ms |
8776 KB |
Output is correct |
17 |
Correct |
5 ms |
8780 KB |
Output is correct |
18 |
Correct |
5 ms |
8776 KB |
Output is correct |
19 |
Correct |
4 ms |
8780 KB |
Output is correct |
20 |
Correct |
5 ms |
8780 KB |
Output is correct |
21 |
Incorrect |
4 ms |
8780 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8780 KB |
Output is correct |
2 |
Correct |
5 ms |
8780 KB |
Output is correct |
3 |
Correct |
5 ms |
8780 KB |
Output is correct |
4 |
Correct |
5 ms |
8792 KB |
Output is correct |
5 |
Correct |
5 ms |
8780 KB |
Output is correct |
6 |
Correct |
5 ms |
8820 KB |
Output is correct |
7 |
Correct |
5 ms |
8780 KB |
Output is correct |
8 |
Correct |
4 ms |
8780 KB |
Output is correct |
9 |
Correct |
5 ms |
8780 KB |
Output is correct |
10 |
Correct |
5 ms |
8780 KB |
Output is correct |
11 |
Correct |
4 ms |
8780 KB |
Output is correct |
12 |
Correct |
5 ms |
8792 KB |
Output is correct |
13 |
Correct |
5 ms |
8780 KB |
Output is correct |
14 |
Correct |
5 ms |
8780 KB |
Output is correct |
15 |
Correct |
5 ms |
8764 KB |
Output is correct |
16 |
Correct |
4 ms |
8780 KB |
Output is correct |
17 |
Correct |
5 ms |
8808 KB |
Output is correct |
18 |
Correct |
5 ms |
8780 KB |
Output is correct |
19 |
Correct |
5 ms |
8780 KB |
Output is correct |
20 |
Correct |
4 ms |
8772 KB |
Output is correct |
21 |
Incorrect |
4 ms |
8780 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8780 KB |
Output is correct |
2 |
Correct |
4 ms |
8780 KB |
Output is correct |
3 |
Correct |
5 ms |
8780 KB |
Output is correct |
4 |
Correct |
5 ms |
8780 KB |
Output is correct |
5 |
Correct |
4 ms |
8780 KB |
Output is correct |
6 |
Correct |
5 ms |
8780 KB |
Output is correct |
7 |
Correct |
5 ms |
8784 KB |
Output is correct |
8 |
Correct |
5 ms |
8780 KB |
Output is correct |
9 |
Correct |
4 ms |
8780 KB |
Output is correct |
10 |
Correct |
5 ms |
8780 KB |
Output is correct |
11 |
Correct |
5 ms |
8876 KB |
Output is correct |
12 |
Correct |
5 ms |
8780 KB |
Output is correct |
13 |
Correct |
5 ms |
8780 KB |
Output is correct |
14 |
Correct |
5 ms |
8780 KB |
Output is correct |
15 |
Correct |
4 ms |
8780 KB |
Output is correct |
16 |
Correct |
4 ms |
8780 KB |
Output is correct |
17 |
Correct |
5 ms |
8780 KB |
Output is correct |
18 |
Correct |
5 ms |
8780 KB |
Output is correct |
19 |
Correct |
5 ms |
8784 KB |
Output is correct |
20 |
Correct |
5 ms |
8780 KB |
Output is correct |
21 |
Correct |
5 ms |
8780 KB |
Output is correct |
22 |
Correct |
5 ms |
8776 KB |
Output is correct |
23 |
Correct |
5 ms |
8816 KB |
Output is correct |
24 |
Correct |
5 ms |
8780 KB |
Output is correct |
25 |
Correct |
5 ms |
8780 KB |
Output is correct |
26 |
Correct |
5 ms |
8780 KB |
Output is correct |
27 |
Correct |
7 ms |
8780 KB |
Output is correct |
28 |
Correct |
9 ms |
8784 KB |
Output is correct |
29 |
Correct |
8 ms |
8776 KB |
Output is correct |
30 |
Correct |
5 ms |
8780 KB |
Output is correct |
31 |
Correct |
9 ms |
8772 KB |
Output is correct |
32 |
Correct |
8 ms |
8876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8780 KB |
Output is correct |
2 |
Correct |
4 ms |
8780 KB |
Output is correct |
3 |
Correct |
4 ms |
8780 KB |
Output is correct |
4 |
Correct |
5 ms |
8780 KB |
Output is correct |
5 |
Correct |
5 ms |
8768 KB |
Output is correct |
6 |
Correct |
5 ms |
8780 KB |
Output is correct |
7 |
Correct |
5 ms |
8780 KB |
Output is correct |
8 |
Correct |
5 ms |
8780 KB |
Output is correct |
9 |
Correct |
5 ms |
8772 KB |
Output is correct |
10 |
Correct |
4 ms |
8780 KB |
Output is correct |
11 |
Correct |
4 ms |
8780 KB |
Output is correct |
12 |
Correct |
5 ms |
8780 KB |
Output is correct |
13 |
Correct |
5 ms |
8764 KB |
Output is correct |
14 |
Correct |
5 ms |
8780 KB |
Output is correct |
15 |
Correct |
5 ms |
8780 KB |
Output is correct |
16 |
Correct |
5 ms |
8780 KB |
Output is correct |
17 |
Correct |
5 ms |
8780 KB |
Output is correct |
18 |
Correct |
5 ms |
8776 KB |
Output is correct |
19 |
Correct |
5 ms |
8780 KB |
Output is correct |
20 |
Correct |
5 ms |
8780 KB |
Output is correct |
21 |
Incorrect |
5 ms |
8776 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8780 KB |
Output is correct |
2 |
Correct |
4 ms |
8780 KB |
Output is correct |
3 |
Correct |
5 ms |
8780 KB |
Output is correct |
4 |
Correct |
5 ms |
8772 KB |
Output is correct |
5 |
Correct |
5 ms |
8800 KB |
Output is correct |
6 |
Correct |
5 ms |
8780 KB |
Output is correct |
7 |
Correct |
5 ms |
8780 KB |
Output is correct |
8 |
Correct |
4 ms |
8780 KB |
Output is correct |
9 |
Correct |
5 ms |
8772 KB |
Output is correct |
10 |
Correct |
5 ms |
8780 KB |
Output is correct |
11 |
Correct |
5 ms |
8780 KB |
Output is correct |
12 |
Correct |
4 ms |
8828 KB |
Output is correct |
13 |
Correct |
5 ms |
8776 KB |
Output is correct |
14 |
Correct |
5 ms |
8780 KB |
Output is correct |
15 |
Correct |
4 ms |
8780 KB |
Output is correct |
16 |
Correct |
4 ms |
8780 KB |
Output is correct |
17 |
Correct |
4 ms |
8780 KB |
Output is correct |
18 |
Incorrect |
4 ms |
8780 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |