#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 100;
int dp[51][21][8001], n, A, B, a[maxn];
void solve()
{
cin >> n >> A >> B;
for (int i = 1; i <= n; i ++)
{
cin >> a[i];
}
dp[0][0][0] = 1;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= B; j ++)
{
int sum = 0;
for (int k = i; k > 0; k --)
{
sum = sum + a[k];
for (int x = 0; x < 8001; x ++)
{
int new_x = (x | sum);
if (dp[k - 1][j - 1][x] == 1)
dp[i][j][new_x] = 1;
}
}
}
}
int best = 8000;
for (int j = A; j <= B; j ++)
{
for (int x = 0; x < 8000; x ++)
{
if (dp[n][j][x] != 0)
{
best = min(best, x);
break;
}
}
}
cout << best << endl;
}
int main()
{
solve();
return 0;
}
/**
6 1 3
8 1 2 1 5 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
6 |
Correct |
12 ms |
744 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
4 ms |
568 KB |
Output is correct |
13 |
Correct |
23 ms |
1100 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
440 KB |
Output is correct |
19 |
Correct |
11 ms |
724 KB |
Output is correct |
20 |
Correct |
3 ms |
468 KB |
Output is correct |
21 |
Correct |
10 ms |
856 KB |
Output is correct |
22 |
Correct |
13 ms |
740 KB |
Output is correct |
23 |
Correct |
14 ms |
724 KB |
Output is correct |
24 |
Correct |
4 ms |
440 KB |
Output is correct |
25 |
Correct |
10 ms |
724 KB |
Output is correct |
26 |
Correct |
19 ms |
996 KB |
Output is correct |
27 |
Runtime error |
1 ms |
340 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 |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
11 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
524 KB |
Output is correct |
10 |
Correct |
4 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
468 KB |
Output is correct |
13 |
Correct |
28 ms |
1116 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
312 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
13 ms |
696 KB |
Output is correct |
20 |
Correct |
3 ms |
404 KB |
Output is correct |
21 |
Correct |
10 ms |
784 KB |
Output is correct |
22 |
Correct |
9 ms |
724 KB |
Output is correct |
23 |
Correct |
9 ms |
824 KB |
Output is correct |
24 |
Correct |
3 ms |
468 KB |
Output is correct |
25 |
Correct |
9 ms |
836 KB |
Output is correct |
26 |
Correct |
18 ms |
980 KB |
Output is correct |
27 |
Correct |
30 ms |
1292 KB |
Output is correct |
28 |
Correct |
19 ms |
1100 KB |
Output is correct |
29 |
Correct |
22 ms |
1108 KB |
Output is correct |
30 |
Correct |
93 ms |
2896 KB |
Output is correct |
31 |
Correct |
169 ms |
4068 KB |
Output is correct |
32 |
Correct |
141 ms |
4044 KB |
Output is correct |
33 |
Correct |
8 ms |
564 KB |
Output is correct |
34 |
Correct |
146 ms |
3792 KB |
Output is correct |
35 |
Correct |
145 ms |
3404 KB |
Output is correct |
36 |
Correct |
91 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 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 |
340 KB |
Output is correct |
6 |
Correct |
14 ms |
788 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
7 ms |
560 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
7 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
408 KB |
Output is correct |
12 |
Correct |
6 ms |
512 KB |
Output is correct |
13 |
Correct |
24 ms |
1120 KB |
Output is correct |
14 |
Correct |
29 ms |
1224 KB |
Output is correct |
15 |
Correct |
22 ms |
1080 KB |
Output is correct |
16 |
Correct |
22 ms |
1100 KB |
Output is correct |
17 |
Correct |
99 ms |
2900 KB |
Output is correct |
18 |
Correct |
147 ms |
4040 KB |
Output is correct |
19 |
Correct |
141 ms |
4052 KB |
Output is correct |
20 |
Correct |
8 ms |
468 KB |
Output is correct |
21 |
Correct |
144 ms |
3740 KB |
Output is correct |
22 |
Correct |
130 ms |
3416 KB |
Output is correct |
23 |
Correct |
75 ms |
2300 KB |
Output is correct |
24 |
Runtime error |
155 ms |
8220 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
6 |
Correct |
12 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
468 KB |
Output is correct |
8 |
Correct |
4 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
4 ms |
468 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
4 ms |
468 KB |
Output is correct |
13 |
Correct |
22 ms |
1080 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
308 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
468 KB |
Output is correct |
19 |
Correct |
21 ms |
732 KB |
Output is correct |
20 |
Correct |
4 ms |
468 KB |
Output is correct |
21 |
Correct |
11 ms |
724 KB |
Output is correct |
22 |
Correct |
10 ms |
812 KB |
Output is correct |
23 |
Correct |
10 ms |
728 KB |
Output is correct |
24 |
Correct |
3 ms |
468 KB |
Output is correct |
25 |
Correct |
10 ms |
792 KB |
Output is correct |
26 |
Correct |
17 ms |
964 KB |
Output is correct |
27 |
Runtime error |
1 ms |
340 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 |
340 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 |
340 KB |
Output is correct |
6 |
Correct |
18 ms |
696 KB |
Output is correct |
7 |
Correct |
6 ms |
468 KB |
Output is correct |
8 |
Correct |
6 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
468 KB |
Output is correct |
10 |
Correct |
5 ms |
468 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
4 ms |
468 KB |
Output is correct |
13 |
Correct |
21 ms |
1036 KB |
Output is correct |
14 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
15 |
Halted |
0 ms |
0 KB |
- |