#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int INF = 1e18;
void run() {
int n, a, b;
cin >> n >> a >> b;
vector<int> y(n);
for (auto &x : y)
cin >> x;
int ans = INF;
for (int mask = 0; mask < (1 << n); ++mask) {
if (!(mask & 1))
continue;
int cnt = __builtin_popcountll(mask);
if (cnt < a || cnt > b)
continue;
int cur_ans = 0;
int cur_sum = 0;
for (int i = 0; i < n; ++i) {
if (mask & (1 << i)) {
cur_ans |= cur_sum;
cur_sum = 0;
}
cur_sum += y[i];
}
cur_ans |= cur_sum;
if (cur_ans < ans)
ans = cur_ans;
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
run();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
40 ms |
416 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
8 ms |
384 KB |
Output is correct |
22 |
Correct |
8 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
42 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
384 KB |
Output is correct |
31 |
Correct |
7 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
38 ms |
504 KB |
Output is correct |
34 |
Correct |
39 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
384 KB |
Output is correct |
36 |
Correct |
41 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
43 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
8 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
37 ms |
412 KB |
Output is correct |
27 |
Correct |
102 ms |
384 KB |
Output is correct |
28 |
Correct |
273 ms |
384 KB |
Output is correct |
29 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
356 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
44 ms |
384 KB |
Output is correct |
14 |
Correct |
99 ms |
504 KB |
Output is correct |
15 |
Correct |
291 ms |
476 KB |
Output is correct |
16 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
58 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
8 ms |
384 KB |
Output is correct |
22 |
Correct |
9 ms |
384 KB |
Output is correct |
23 |
Correct |
9 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
39 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
8 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
33 |
Correct |
40 ms |
408 KB |
Output is correct |
34 |
Correct |
44 ms |
376 KB |
Output is correct |
35 |
Correct |
4 ms |
256 KB |
Output is correct |
36 |
Correct |
42 ms |
256 KB |
Output is correct |
37 |
Correct |
81 ms |
256 KB |
Output is correct |
38 |
Correct |
279 ms |
380 KB |
Output is correct |
39 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
44 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
7 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
37 ms |
384 KB |
Output is correct |
21 |
Correct |
40 ms |
376 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
40 ms |
384 KB |
Output is correct |
24 |
Correct |
107 ms |
384 KB |
Output is correct |
25 |
Correct |
268 ms |
384 KB |
Output is correct |
26 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |