#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = (int)2e3+10;
const int LINF = (int)1e18;
int n, A, B, ans=LINF;
int a[maxn];
int32_t main() {
cin >> n >> A >> B;
for(int i = 0; i < n; i++) cin >> a[i];
for(int mask = 0; mask < (1<<n); mask++){
int num = __builtin_popcount(mask);
if(num<A or num>B or !(mask&(1<<(n-1)))) continue;
int Or = 0, sum = 0;
for(int i = 0; i < n; i++){
if(mask&(1<<i)) sum+=a[i], Or|=sum, sum=0;
else sum+=a[i];
}
ans = min(ans, Or);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
32 ms |
280 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
304 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
212 KB |
Output is correct |
22 |
Correct |
6 ms |
300 KB |
Output is correct |
23 |
Correct |
6 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
6 ms |
212 KB |
Output is correct |
26 |
Correct |
31 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
304 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
6 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
212 KB |
Output is correct |
33 |
Correct |
29 ms |
288 KB |
Output is correct |
34 |
Correct |
32 ms |
212 KB |
Output is correct |
35 |
Correct |
3 ms |
212 KB |
Output is correct |
36 |
Correct |
31 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
212 KB |
Output is correct |
22 |
Correct |
6 ms |
212 KB |
Output is correct |
23 |
Correct |
6 ms |
300 KB |
Output is correct |
24 |
Correct |
3 ms |
212 KB |
Output is correct |
25 |
Correct |
6 ms |
212 KB |
Output is correct |
26 |
Correct |
30 ms |
280 KB |
Output is correct |
27 |
Correct |
62 ms |
284 KB |
Output is correct |
28 |
Correct |
254 ms |
284 KB |
Output is correct |
29 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
300 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
33 ms |
280 KB |
Output is correct |
14 |
Correct |
63 ms |
284 KB |
Output is correct |
15 |
Correct |
251 ms |
212 KB |
Output is correct |
16 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
228 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
304 KB |
Output is correct |
13 |
Correct |
32 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
6 ms |
212 KB |
Output is correct |
22 |
Correct |
5 ms |
212 KB |
Output is correct |
23 |
Correct |
6 ms |
304 KB |
Output is correct |
24 |
Correct |
3 ms |
308 KB |
Output is correct |
25 |
Correct |
6 ms |
212 KB |
Output is correct |
26 |
Correct |
28 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
304 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
6 ms |
304 KB |
Output is correct |
32 |
Correct |
3 ms |
212 KB |
Output is correct |
33 |
Correct |
30 ms |
212 KB |
Output is correct |
34 |
Correct |
31 ms |
212 KB |
Output is correct |
35 |
Correct |
3 ms |
212 KB |
Output is correct |
36 |
Correct |
31 ms |
284 KB |
Output is correct |
37 |
Correct |
63 ms |
212 KB |
Output is correct |
38 |
Correct |
249 ms |
280 KB |
Output is correct |
39 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
32 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
6 ms |
212 KB |
Output is correct |
19 |
Correct |
3 ms |
212 KB |
Output is correct |
20 |
Correct |
29 ms |
212 KB |
Output is correct |
21 |
Correct |
31 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
31 ms |
296 KB |
Output is correct |
24 |
Correct |
63 ms |
212 KB |
Output is correct |
25 |
Correct |
251 ms |
280 KB |
Output is correct |
26 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |