#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=(1e18)+10;
int main(){
ll n, a, b, i, j;
cin>>n>>a>>b;
vector<ll> v(n, 0);
for(i=0; i<n; i++){
cin>>v[i];
}
if(n==1){
cout<<v[0];
return 0;
}
a--, b--;
ll mn=inf;
for(i=0; i<(1<<(n-1)); i++){
ll s1=0;
for(j=0; j<n-1; j++){
if((i & (1<<j)) > 0){
s1++;
}
}
if(s1<a || s1>b) continue;
ll s=0, k=0;
for(j=0; j<n-1; j++){
s+=v[n-1-j];
if((i & (1<<j)) > 0){
k=(k|s);
s=0;
}
}
s+=v[0];
k=(k|s);
mn=min(k, mn);
}
cout<<mn;
return 0;
}
# |
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 |
1 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 |
296 KB |
Output is correct |
8 |
Correct |
9 ms |
212 KB |
Output is correct |
9 |
Correct |
10 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
304 KB |
Output is correct |
11 |
Correct |
8 ms |
212 KB |
Output is correct |
12 |
Correct |
9 ms |
304 KB |
Output is correct |
13 |
Correct |
38 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
296 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 |
300 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
11 ms |
300 KB |
Output is correct |
22 |
Correct |
14 ms |
212 KB |
Output is correct |
23 |
Correct |
13 ms |
212 KB |
Output is correct |
24 |
Correct |
8 ms |
300 KB |
Output is correct |
25 |
Correct |
13 ms |
292 KB |
Output is correct |
26 |
Correct |
35 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
4 ms |
212 KB |
Output is correct |
31 |
Correct |
11 ms |
212 KB |
Output is correct |
32 |
Correct |
9 ms |
304 KB |
Output is correct |
33 |
Correct |
35 ms |
300 KB |
Output is correct |
34 |
Correct |
37 ms |
212 KB |
Output is correct |
35 |
Correct |
8 ms |
212 KB |
Output is correct |
36 |
Correct |
41 ms |
280 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
9 ms |
212 KB |
Output is correct |
9 |
Correct |
9 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
300 KB |
Output is correct |
11 |
Correct |
9 ms |
300 KB |
Output is correct |
12 |
Correct |
8 ms |
296 KB |
Output is correct |
13 |
Correct |
47 ms |
280 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 |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
11 ms |
304 KB |
Output is correct |
22 |
Correct |
11 ms |
300 KB |
Output is correct |
23 |
Correct |
11 ms |
300 KB |
Output is correct |
24 |
Correct |
8 ms |
300 KB |
Output is correct |
25 |
Correct |
16 ms |
212 KB |
Output is correct |
26 |
Correct |
46 ms |
280 KB |
Output is correct |
27 |
Correct |
76 ms |
212 KB |
Output is correct |
28 |
Correct |
487 ms |
276 KB |
Output is correct |
29 |
Incorrect |
1 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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
1 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 |
11 ms |
212 KB |
Output is correct |
9 |
Correct |
9 ms |
212 KB |
Output is correct |
10 |
Correct |
9 ms |
212 KB |
Output is correct |
11 |
Correct |
11 ms |
212 KB |
Output is correct |
12 |
Correct |
8 ms |
300 KB |
Output is correct |
13 |
Correct |
38 ms |
276 KB |
Output is correct |
14 |
Correct |
78 ms |
212 KB |
Output is correct |
15 |
Correct |
555 ms |
280 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
300 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
300 KB |
Output is correct |
8 |
Correct |
9 ms |
300 KB |
Output is correct |
9 |
Correct |
9 ms |
296 KB |
Output is correct |
10 |
Correct |
8 ms |
304 KB |
Output is correct |
11 |
Correct |
10 ms |
296 KB |
Output is correct |
12 |
Correct |
11 ms |
300 KB |
Output is correct |
13 |
Correct |
46 ms |
276 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 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 |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
300 KB |
Output is correct |
21 |
Correct |
11 ms |
304 KB |
Output is correct |
22 |
Correct |
15 ms |
300 KB |
Output is correct |
23 |
Correct |
11 ms |
300 KB |
Output is correct |
24 |
Correct |
9 ms |
296 KB |
Output is correct |
25 |
Correct |
14 ms |
296 KB |
Output is correct |
26 |
Correct |
37 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
296 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
5 ms |
304 KB |
Output is correct |
31 |
Correct |
14 ms |
300 KB |
Output is correct |
32 |
Correct |
9 ms |
212 KB |
Output is correct |
33 |
Correct |
36 ms |
212 KB |
Output is correct |
34 |
Correct |
38 ms |
212 KB |
Output is correct |
35 |
Correct |
8 ms |
212 KB |
Output is correct |
36 |
Correct |
46 ms |
280 KB |
Output is correct |
37 |
Correct |
78 ms |
212 KB |
Output is correct |
38 |
Correct |
503 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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
11 ms |
300 KB |
Output is correct |
9 |
Correct |
9 ms |
212 KB |
Output is correct |
10 |
Correct |
10 ms |
212 KB |
Output is correct |
11 |
Correct |
8 ms |
212 KB |
Output is correct |
12 |
Correct |
10 ms |
304 KB |
Output is correct |
13 |
Correct |
41 ms |
296 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
4 ms |
296 KB |
Output is correct |
18 |
Correct |
16 ms |
288 KB |
Output is correct |
19 |
Correct |
9 ms |
300 KB |
Output is correct |
20 |
Correct |
36 ms |
212 KB |
Output is correct |
21 |
Correct |
37 ms |
212 KB |
Output is correct |
22 |
Correct |
9 ms |
212 KB |
Output is correct |
23 |
Correct |
45 ms |
280 KB |
Output is correct |
24 |
Correct |
81 ms |
284 KB |
Output is correct |
25 |
Correct |
483 ms |
288 KB |
Output is correct |
26 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |