#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = (int)53;
const ll LINF = (ll)1e18;
int n, A, B;
ll a[maxn], pre[maxn]; int ans=1029;
bool dp[maxn][maxn][25][1028];
void recur(int pos, int lpos, int knum, int Or){
if(dp[pos][lpos][knum][Or]) return;
dp[pos][lpos][knum][Or]=1;
if(pos==n+1) return;
if(pos!=n) recur(pos+1, lpos, knum, Or);
recur(pos+1, pos, knum+1, Or|(pre[pos]-pre[lpos]));
}
int32_t main() {
cin >> n >> A >> B;
for(int i = 0; i < n; i++) cin >> a[i], pre[i+1]=pre[i]+a[i];
recur(1,0,1,0);
for(int i = A+1; i <= B+1; i++)
for(int k = 0; k < 1028; k++)
if(dp[n+1][n][i][k]) ans = min(ans, k);
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
2 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2340 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
1236 KB |
Output is correct |
20 |
Correct |
1 ms |
1620 KB |
Output is correct |
21 |
Correct |
2 ms |
2260 KB |
Output is correct |
22 |
Correct |
2 ms |
2260 KB |
Output is correct |
23 |
Correct |
2 ms |
2260 KB |
Output is correct |
24 |
Correct |
2 ms |
2260 KB |
Output is correct |
25 |
Correct |
2 ms |
2260 KB |
Output is correct |
26 |
Correct |
2 ms |
2260 KB |
Output is correct |
27 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
2244 KB |
Output is correct |
9 |
Correct |
2 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
1 ms |
1236 KB |
Output is correct |
20 |
Correct |
1 ms |
1540 KB |
Output is correct |
21 |
Correct |
2 ms |
2260 KB |
Output is correct |
22 |
Correct |
2 ms |
2260 KB |
Output is correct |
23 |
Correct |
2 ms |
2260 KB |
Output is correct |
24 |
Correct |
2 ms |
2260 KB |
Output is correct |
25 |
Correct |
2 ms |
2260 KB |
Output is correct |
26 |
Correct |
2 ms |
2260 KB |
Output is correct |
27 |
Correct |
2 ms |
2644 KB |
Output is correct |
28 |
Correct |
4 ms |
3920 KB |
Output is correct |
29 |
Correct |
11 ms |
11220 KB |
Output is correct |
30 |
Correct |
11 ms |
14428 KB |
Output is correct |
31 |
Correct |
20 ms |
21904 KB |
Output is correct |
32 |
Correct |
17 ms |
21844 KB |
Output is correct |
33 |
Correct |
18 ms |
21836 KB |
Output is correct |
34 |
Correct |
21 ms |
21880 KB |
Output is correct |
35 |
Correct |
18 ms |
21792 KB |
Output is correct |
36 |
Correct |
20 ms |
21804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 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 |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
2 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
1 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2364 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
2 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
3924 KB |
Output is correct |
16 |
Correct |
8 ms |
11260 KB |
Output is correct |
17 |
Correct |
13 ms |
14328 KB |
Output is correct |
18 |
Correct |
19 ms |
21888 KB |
Output is correct |
19 |
Correct |
16 ms |
21844 KB |
Output is correct |
20 |
Correct |
16 ms |
21812 KB |
Output is correct |
21 |
Correct |
16 ms |
21844 KB |
Output is correct |
22 |
Correct |
20 ms |
21924 KB |
Output is correct |
23 |
Correct |
18 ms |
21908 KB |
Output is correct |
24 |
Runtime error |
42 ms |
42056 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
440 KB |
Output is correct |
5 |
Correct |
0 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1188 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
1 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
596 KB |
Output is correct |
19 |
Correct |
2 ms |
1236 KB |
Output is correct |
20 |
Correct |
1 ms |
1552 KB |
Output is correct |
21 |
Correct |
2 ms |
2260 KB |
Output is correct |
22 |
Correct |
2 ms |
2260 KB |
Output is correct |
23 |
Correct |
2 ms |
2260 KB |
Output is correct |
24 |
Correct |
2 ms |
2260 KB |
Output is correct |
25 |
Correct |
2 ms |
2260 KB |
Output is correct |
26 |
Correct |
1 ms |
2260 KB |
Output is correct |
27 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1620 KB |
Output is correct |
8 |
Correct |
2 ms |
2260 KB |
Output is correct |
9 |
Correct |
2 ms |
2260 KB |
Output is correct |
10 |
Correct |
1 ms |
2260 KB |
Output is correct |
11 |
Correct |
1 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
2 ms |
2260 KB |
Output is correct |
14 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |