#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define sz(x) (int)x.size()
#define ff first
#define ss second
const ll N = 300005;
const ll M = 1e9 + 7;
ll T, n, c[N], ans = 1e9, d[N], a, b;
void f(int x){
if(x == n+1){
ll y = 0, z = 0, cnt = 0;
for(int i = 1; i <= n; i++){
z += c[i];
if(d[i] == 1){
cnt++;
y = (y|z);
z = 0;
}
}
if(z != 0) cnt++;
y = (y|z);
z = 0;
if(cnt <= b and cnt >= a) ans = min(ans,y);
return;
}
d[x] = 0;
f(x+1);
d[x] = 1;
f(x+1);
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> a >> b;
for(int i = 1; i <= n; i++){
cin >> c[i];
}
f(1);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
41 ms |
2492 KB |
Output is correct |
9 |
Correct |
41 ms |
2392 KB |
Output is correct |
10 |
Correct |
41 ms |
2396 KB |
Output is correct |
11 |
Correct |
41 ms |
2396 KB |
Output is correct |
12 |
Correct |
41 ms |
2392 KB |
Output is correct |
13 |
Correct |
41 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
5 ms |
2396 KB |
Output is correct |
21 |
Correct |
42 ms |
2516 KB |
Output is correct |
22 |
Correct |
42 ms |
2396 KB |
Output is correct |
23 |
Correct |
42 ms |
2396 KB |
Output is correct |
24 |
Correct |
42 ms |
2392 KB |
Output is correct |
25 |
Correct |
42 ms |
2392 KB |
Output is correct |
26 |
Correct |
47 ms |
2392 KB |
Output is correct |
27 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
41 ms |
2488 KB |
Output is correct |
9 |
Correct |
41 ms |
2396 KB |
Output is correct |
10 |
Correct |
41 ms |
2396 KB |
Output is correct |
11 |
Correct |
41 ms |
2396 KB |
Output is correct |
12 |
Correct |
41 ms |
2392 KB |
Output is correct |
13 |
Correct |
41 ms |
2480 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2392 KB |
Output is correct |
20 |
Correct |
5 ms |
2396 KB |
Output is correct |
21 |
Correct |
42 ms |
2396 KB |
Output is correct |
22 |
Correct |
42 ms |
2396 KB |
Output is correct |
23 |
Correct |
43 ms |
2396 KB |
Output is correct |
24 |
Correct |
41 ms |
2392 KB |
Output is correct |
25 |
Correct |
42 ms |
2396 KB |
Output is correct |
26 |
Correct |
43 ms |
2396 KB |
Output is correct |
27 |
Correct |
87 ms |
2396 KB |
Output is correct |
28 |
Execution timed out |
1004 ms |
2392 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2392 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
41 ms |
2396 KB |
Output is correct |
9 |
Correct |
39 ms |
2488 KB |
Output is correct |
10 |
Correct |
41 ms |
2396 KB |
Output is correct |
11 |
Correct |
41 ms |
2396 KB |
Output is correct |
12 |
Correct |
41 ms |
2396 KB |
Output is correct |
13 |
Correct |
41 ms |
2392 KB |
Output is correct |
14 |
Correct |
83 ms |
2396 KB |
Output is correct |
15 |
Execution timed out |
1078 ms |
2396 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
43 ms |
2396 KB |
Output is correct |
9 |
Correct |
44 ms |
2396 KB |
Output is correct |
10 |
Correct |
41 ms |
2396 KB |
Output is correct |
11 |
Correct |
41 ms |
2396 KB |
Output is correct |
12 |
Correct |
41 ms |
2488 KB |
Output is correct |
13 |
Correct |
41 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
2 ms |
2512 KB |
Output is correct |
20 |
Correct |
5 ms |
2396 KB |
Output is correct |
21 |
Correct |
42 ms |
2396 KB |
Output is correct |
22 |
Correct |
42 ms |
2396 KB |
Output is correct |
23 |
Correct |
41 ms |
2492 KB |
Output is correct |
24 |
Correct |
40 ms |
2396 KB |
Output is correct |
25 |
Correct |
42 ms |
2396 KB |
Output is correct |
26 |
Correct |
43 ms |
2392 KB |
Output is correct |
27 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
2 ms |
2396 KB |
Output is correct |
7 |
Correct |
5 ms |
2396 KB |
Output is correct |
8 |
Correct |
41 ms |
2396 KB |
Output is correct |
9 |
Correct |
42 ms |
2396 KB |
Output is correct |
10 |
Correct |
49 ms |
2396 KB |
Output is correct |
11 |
Correct |
41 ms |
2392 KB |
Output is correct |
12 |
Correct |
41 ms |
2484 KB |
Output is correct |
13 |
Correct |
41 ms |
2392 KB |
Output is correct |
14 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |