# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
int n, ar[N], a, b;
long long ans = 1e18;
int main(){
cin >> n >> a >> b;
for(int i = 0; i < n; i ++)
cin >> ar[i];
if(n > 20) return 0;
for(int mask = 0; mask < (1 << n); mask ++){
int last = -1, cnt = 0;
for(int i = 0; i < n; i ++){
int bit = (1 << i) & mask;
if(bit) bit = 1;
if(bit != last) cnt ++;
last = bit;
}
if(a <= cnt && cnt <= b){
long long res = 0, sum = 0;
last = -1;
for(int i = 0; i < n; i ++){
int bit = (1 << i) & mask;
if(bit) bit = 1;
if(bit != last){
res |= sum;
sum = 0;
}
sum += ar[i];
last = bit;
}
res |= sum;
ans = min(ans, res);
}
}
cout << ans << endl;
}
/**
6 1 3
8 1 2 1 5 4
**/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
2 ms |
700 KB |
Output is correct |
5 |
Correct |
2 ms |
700 KB |
Output is correct |
6 |
Correct |
6 ms |
700 KB |
Output is correct |
7 |
Correct |
7 ms |
700 KB |
Output is correct |
8 |
Correct |
49 ms |
700 KB |
Output is correct |
9 |
Correct |
73 ms |
700 KB |
Output is correct |
10 |
Correct |
50 ms |
752 KB |
Output is correct |
11 |
Correct |
76 ms |
752 KB |
Output is correct |
12 |
Correct |
64 ms |
752 KB |
Output is correct |
13 |
Correct |
174 ms |
752 KB |
Output is correct |
14 |
Correct |
2 ms |
752 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
2 ms |
752 KB |
Output is correct |
17 |
Correct |
2 ms |
752 KB |
Output is correct |
18 |
Correct |
2 ms |
752 KB |
Output is correct |
19 |
Correct |
3 ms |
752 KB |
Output is correct |
20 |
Correct |
6 ms |
752 KB |
Output is correct |
21 |
Correct |
91 ms |
752 KB |
Output is correct |
22 |
Correct |
86 ms |
752 KB |
Output is correct |
23 |
Correct |
51 ms |
752 KB |
Output is correct |
24 |
Correct |
43 ms |
752 KB |
Output is correct |
25 |
Correct |
56 ms |
752 KB |
Output is correct |
26 |
Correct |
129 ms |
752 KB |
Output is correct |
27 |
Correct |
2 ms |
756 KB |
Output is correct |
28 |
Correct |
2 ms |
756 KB |
Output is correct |
29 |
Correct |
3 ms |
756 KB |
Output is correct |
30 |
Correct |
21 ms |
756 KB |
Output is correct |
31 |
Correct |
52 ms |
772 KB |
Output is correct |
32 |
Correct |
42 ms |
772 KB |
Output is correct |
33 |
Correct |
136 ms |
820 KB |
Output is correct |
34 |
Correct |
136 ms |
952 KB |
Output is correct |
35 |
Correct |
42 ms |
952 KB |
Output is correct |
36 |
Correct |
139 ms |
952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
952 KB |
Output is correct |
2 |
Correct |
2 ms |
952 KB |
Output is correct |
3 |
Correct |
2 ms |
952 KB |
Output is correct |
4 |
Correct |
2 ms |
952 KB |
Output is correct |
5 |
Correct |
2 ms |
952 KB |
Output is correct |
6 |
Correct |
6 ms |
952 KB |
Output is correct |
7 |
Correct |
6 ms |
952 KB |
Output is correct |
8 |
Correct |
43 ms |
952 KB |
Output is correct |
9 |
Correct |
42 ms |
952 KB |
Output is correct |
10 |
Correct |
43 ms |
952 KB |
Output is correct |
11 |
Correct |
45 ms |
952 KB |
Output is correct |
12 |
Correct |
55 ms |
952 KB |
Output is correct |
13 |
Correct |
142 ms |
952 KB |
Output is correct |
14 |
Correct |
2 ms |
952 KB |
Output is correct |
15 |
Correct |
2 ms |
952 KB |
Output is correct |
16 |
Correct |
2 ms |
952 KB |
Output is correct |
17 |
Correct |
2 ms |
952 KB |
Output is correct |
18 |
Correct |
3 ms |
952 KB |
Output is correct |
19 |
Correct |
3 ms |
952 KB |
Output is correct |
20 |
Correct |
10 ms |
952 KB |
Output is correct |
21 |
Correct |
50 ms |
952 KB |
Output is correct |
22 |
Correct |
50 ms |
952 KB |
Output is correct |
23 |
Correct |
50 ms |
952 KB |
Output is correct |
24 |
Correct |
44 ms |
952 KB |
Output is correct |
25 |
Correct |
58 ms |
952 KB |
Output is correct |
26 |
Correct |
145 ms |
952 KB |
Output is correct |
27 |
Incorrect |
2 ms |
952 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
952 KB |
Output is correct |
2 |
Correct |
2 ms |
952 KB |
Output is correct |
3 |
Correct |
2 ms |
952 KB |
Output is correct |
4 |
Correct |
2 ms |
952 KB |
Output is correct |
5 |
Correct |
2 ms |
952 KB |
Output is correct |
6 |
Correct |
6 ms |
952 KB |
Output is correct |
7 |
Correct |
7 ms |
952 KB |
Output is correct |
8 |
Correct |
68 ms |
952 KB |
Output is correct |
9 |
Correct |
46 ms |
952 KB |
Output is correct |
10 |
Correct |
45 ms |
952 KB |
Output is correct |
11 |
Correct |
73 ms |
952 KB |
Output is correct |
12 |
Correct |
44 ms |
952 KB |
Output is correct |
13 |
Correct |
144 ms |
1072 KB |
Output is correct |
14 |
Incorrect |
2 ms |
1072 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1072 KB |
Output is correct |
2 |
Correct |
2 ms |
1072 KB |
Output is correct |
3 |
Correct |
2 ms |
1072 KB |
Output is correct |
4 |
Correct |
2 ms |
1072 KB |
Output is correct |
5 |
Correct |
2 ms |
1072 KB |
Output is correct |
6 |
Correct |
5 ms |
1072 KB |
Output is correct |
7 |
Correct |
6 ms |
1072 KB |
Output is correct |
8 |
Correct |
42 ms |
1072 KB |
Output is correct |
9 |
Correct |
42 ms |
1072 KB |
Output is correct |
10 |
Correct |
41 ms |
1072 KB |
Output is correct |
11 |
Correct |
42 ms |
1072 KB |
Output is correct |
12 |
Correct |
54 ms |
1072 KB |
Output is correct |
13 |
Correct |
165 ms |
1072 KB |
Output is correct |
14 |
Correct |
2 ms |
1072 KB |
Output is correct |
15 |
Correct |
2 ms |
1072 KB |
Output is correct |
16 |
Correct |
2 ms |
1072 KB |
Output is correct |
17 |
Correct |
2 ms |
1072 KB |
Output is correct |
18 |
Correct |
2 ms |
1072 KB |
Output is correct |
19 |
Correct |
3 ms |
1072 KB |
Output is correct |
20 |
Correct |
6 ms |
1072 KB |
Output is correct |
21 |
Correct |
54 ms |
1140 KB |
Output is correct |
22 |
Correct |
59 ms |
1140 KB |
Output is correct |
23 |
Correct |
52 ms |
1156 KB |
Output is correct |
24 |
Correct |
41 ms |
1156 KB |
Output is correct |
25 |
Correct |
57 ms |
1156 KB |
Output is correct |
26 |
Correct |
126 ms |
1156 KB |
Output is correct |
27 |
Correct |
2 ms |
1156 KB |
Output is correct |
28 |
Correct |
2 ms |
1156 KB |
Output is correct |
29 |
Correct |
3 ms |
1156 KB |
Output is correct |
30 |
Correct |
20 ms |
1156 KB |
Output is correct |
31 |
Correct |
48 ms |
1156 KB |
Output is correct |
32 |
Correct |
42 ms |
1156 KB |
Output is correct |
33 |
Correct |
137 ms |
1156 KB |
Output is correct |
34 |
Correct |
142 ms |
1156 KB |
Output is correct |
35 |
Correct |
45 ms |
1156 KB |
Output is correct |
36 |
Correct |
137 ms |
1156 KB |
Output is correct |
37 |
Incorrect |
2 ms |
1156 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1156 KB |
Output is correct |
2 |
Correct |
2 ms |
1156 KB |
Output is correct |
3 |
Correct |
2 ms |
1156 KB |
Output is correct |
4 |
Correct |
2 ms |
1156 KB |
Output is correct |
5 |
Correct |
2 ms |
1156 KB |
Output is correct |
6 |
Correct |
5 ms |
1156 KB |
Output is correct |
7 |
Correct |
9 ms |
1156 KB |
Output is correct |
8 |
Correct |
57 ms |
1156 KB |
Output is correct |
9 |
Correct |
41 ms |
1156 KB |
Output is correct |
10 |
Correct |
43 ms |
1156 KB |
Output is correct |
11 |
Correct |
45 ms |
1156 KB |
Output is correct |
12 |
Correct |
48 ms |
1156 KB |
Output is correct |
13 |
Correct |
139 ms |
1156 KB |
Output is correct |
14 |
Correct |
2 ms |
1156 KB |
Output is correct |
15 |
Correct |
2 ms |
1156 KB |
Output is correct |
16 |
Correct |
4 ms |
1156 KB |
Output is correct |
17 |
Correct |
20 ms |
1156 KB |
Output is correct |
18 |
Correct |
48 ms |
1160 KB |
Output is correct |
19 |
Correct |
44 ms |
1164 KB |
Output is correct |
20 |
Correct |
135 ms |
1164 KB |
Output is correct |
21 |
Correct |
138 ms |
1172 KB |
Output is correct |
22 |
Correct |
46 ms |
1172 KB |
Output is correct |
23 |
Correct |
139 ms |
1180 KB |
Output is correct |
24 |
Incorrect |
2 ms |
1180 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |