#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
ll arr[2010];
ll memo[100][100][410];
ll a, b;
const ll inf = 1e18;
ll rek( int p, int k, int o ) {
if(p==n) {
if(k>=a&&k<=b) return o;
return inf;
}
if(memo[p][k][o]) return memo[p][k][o];
ll sum = 0, ans = inf;
for(int i = p; i < n; i++) {
sum += arr[i];
ans = min(rek(i+1, k+1, o|sum), ans);
}
memo[p][k][o] = ans;
return ans;
}
int main( void ) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> a >> b;
for(int i = 0; i < n; i++) cin >> arr[i];
cout << rek(0, 0, 0);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
708 KB |
Output is correct |
8 |
Correct |
1 ms |
968 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
1 ms |
836 KB |
Output is correct |
11 |
Correct |
1 ms |
852 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
2 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 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 |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
2 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
852 KB |
Output is correct |
23 |
Correct |
1 ms |
852 KB |
Output is correct |
24 |
Correct |
1 ms |
852 KB |
Output is correct |
25 |
Correct |
1 ms |
852 KB |
Output is correct |
26 |
Correct |
1 ms |
852 KB |
Output is correct |
27 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
372 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
584 KB |
Output is correct |
7 |
Correct |
1 ms |
708 KB |
Output is correct |
8 |
Correct |
1 ms |
852 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
1 ms |
852 KB |
Output is correct |
11 |
Correct |
1 ms |
852 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 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 |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
588 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
1 ms |
852 KB |
Output is correct |
22 |
Correct |
1 ms |
852 KB |
Output is correct |
23 |
Correct |
1 ms |
852 KB |
Output is correct |
24 |
Correct |
1 ms |
852 KB |
Output is correct |
25 |
Correct |
1 ms |
852 KB |
Output is correct |
26 |
Correct |
1 ms |
852 KB |
Output is correct |
27 |
Correct |
1 ms |
980 KB |
Output is correct |
28 |
Correct |
1 ms |
1236 KB |
Output is correct |
29 |
Correct |
2 ms |
2516 KB |
Output is correct |
30 |
Correct |
3 ms |
3012 KB |
Output is correct |
31 |
Correct |
4 ms |
4180 KB |
Output is correct |
32 |
Correct |
3 ms |
4180 KB |
Output is correct |
33 |
Correct |
3 ms |
4168 KB |
Output is correct |
34 |
Correct |
4 ms |
4180 KB |
Output is correct |
35 |
Correct |
4 ms |
4164 KB |
Output is correct |
36 |
Correct |
4 ms |
4168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
328 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 |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
852 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
1 ms |
852 KB |
Output is correct |
11 |
Correct |
1 ms |
840 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
980 KB |
Output is correct |
15 |
Correct |
1 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
2516 KB |
Output is correct |
17 |
Correct |
2 ms |
3028 KB |
Output is correct |
18 |
Correct |
5 ms |
4172 KB |
Output is correct |
19 |
Correct |
3 ms |
4180 KB |
Output is correct |
20 |
Correct |
3 ms |
4180 KB |
Output is correct |
21 |
Correct |
4 ms |
4180 KB |
Output is correct |
22 |
Correct |
5 ms |
4180 KB |
Output is correct |
23 |
Correct |
4 ms |
4180 KB |
Output is correct |
24 |
Correct |
6 ms |
4376 KB |
Output is correct |
25 |
Correct |
12 ms |
6868 KB |
Output is correct |
26 |
Correct |
20 ms |
9748 KB |
Output is correct |
27 |
Correct |
26 ms |
13184 KB |
Output is correct |
28 |
Correct |
34 ms |
15884 KB |
Output is correct |
29 |
Correct |
26 ms |
15632 KB |
Output is correct |
30 |
Correct |
26 ms |
15624 KB |
Output is correct |
31 |
Correct |
38 ms |
15888 KB |
Output is correct |
32 |
Correct |
39 ms |
15812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
336 KB |
Output is correct |
5 |
Correct |
0 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
580 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
968 KB |
Output is correct |
9 |
Correct |
1 ms |
840 KB |
Output is correct |
10 |
Correct |
1 ms |
852 KB |
Output is correct |
11 |
Correct |
1 ms |
852 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
276 KB |
Output is correct |
18 |
Correct |
1 ms |
468 KB |
Output is correct |
19 |
Correct |
1 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
724 KB |
Output is correct |
21 |
Correct |
1 ms |
852 KB |
Output is correct |
22 |
Correct |
1 ms |
844 KB |
Output is correct |
23 |
Correct |
1 ms |
852 KB |
Output is correct |
24 |
Correct |
1 ms |
852 KB |
Output is correct |
25 |
Correct |
1 ms |
852 KB |
Output is correct |
26 |
Correct |
1 ms |
852 KB |
Output is correct |
27 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 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 |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
672 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
852 KB |
Output is correct |
9 |
Correct |
1 ms |
852 KB |
Output is correct |
10 |
Correct |
1 ms |
852 KB |
Output is correct |
11 |
Correct |
1 ms |
852 KB |
Output is correct |
12 |
Correct |
1 ms |
852 KB |
Output is correct |
13 |
Correct |
1 ms |
968 KB |
Output is correct |
14 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |