#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn = 30;
ll arr[mxn];
ll pre[mxn];
int main()
{
int n, a, b;
cin >> n;
cin >> a >> b;
for(int i = 0; i < n; i++) cin >> arr[i];
pre[0] = arr[0];
for(int i = 1; i < n; i++) pre[i] = arr[i]+pre[i-1];
ll lim = 1<<(n-1);
ll res = LLONG_MAX;
for(int i = 0; i < lim; i++)
{
int cnt = __builtin_popcount(i)+1;
if(cnt<a || cnt>b) continue;
ll ans = 0, last = -1;
for(int r = 0; r < n; r++)
{
ll sum = 0;
if(i&(1<<r) || r==n-1)
{
if(last==-1) sum = pre[r];
else sum = pre[r]-pre[last];
last = r;
ans = ans|sum;
}
}
res = min(res, ans);
}
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
44 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
360 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
380 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
7 ms |
376 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
7 ms |
376 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
7 ms |
256 KB |
Output is correct |
26 |
Correct |
39 ms |
256 KB |
Output is correct |
27 |
Correct |
2 ms |
256 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
29 |
Correct |
2 ms |
256 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
7 ms |
256 KB |
Output is correct |
32 |
Correct |
4 ms |
376 KB |
Output is correct |
33 |
Correct |
39 ms |
256 KB |
Output is correct |
34 |
Correct |
42 ms |
380 KB |
Output is correct |
35 |
Correct |
4 ms |
256 KB |
Output is correct |
36 |
Correct |
42 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
252 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
256 KB |
Output is correct |
13 |
Correct |
44 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
7 ms |
380 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
8 ms |
376 KB |
Output is correct |
24 |
Correct |
5 ms |
376 KB |
Output is correct |
25 |
Correct |
8 ms |
276 KB |
Output is correct |
26 |
Correct |
39 ms |
376 KB |
Output is correct |
27 |
Correct |
84 ms |
256 KB |
Output is correct |
28 |
Correct |
273 ms |
360 KB |
Output is correct |
29 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
42 ms |
376 KB |
Output is correct |
14 |
Correct |
84 ms |
252 KB |
Output is correct |
15 |
Correct |
271 ms |
352 KB |
Output is correct |
16 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
4 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
42 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
252 KB |
Output is correct |
21 |
Correct |
7 ms |
256 KB |
Output is correct |
22 |
Correct |
7 ms |
256 KB |
Output is correct |
23 |
Correct |
7 ms |
256 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
8 ms |
276 KB |
Output is correct |
26 |
Correct |
39 ms |
256 KB |
Output is correct |
27 |
Correct |
3 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
29 |
Correct |
3 ms |
256 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
7 ms |
376 KB |
Output is correct |
32 |
Correct |
4 ms |
256 KB |
Output is correct |
33 |
Correct |
40 ms |
256 KB |
Output is correct |
34 |
Correct |
43 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
44 ms |
364 KB |
Output is correct |
37 |
Correct |
84 ms |
376 KB |
Output is correct |
38 |
Correct |
274 ms |
356 KB |
Output is correct |
39 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
292 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
43 ms |
356 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
7 ms |
376 KB |
Output is correct |
19 |
Correct |
4 ms |
256 KB |
Output is correct |
20 |
Correct |
39 ms |
256 KB |
Output is correct |
21 |
Correct |
43 ms |
376 KB |
Output is correct |
22 |
Correct |
4 ms |
256 KB |
Output is correct |
23 |
Correct |
45 ms |
376 KB |
Output is correct |
24 |
Correct |
84 ms |
356 KB |
Output is correct |
25 |
Correct |
270 ms |
364 KB |
Output is correct |
26 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |