#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n, a, b;
cin >> n >> a >> b;
vector<int> v(n);
for (int i=0; i<n; i++) cin >> v[i];
int bsf = pow(10, 11);
for (int i=0; i<(1<<(n-1)); i++){
//cout << i << "\n";
int pc = 0;
for (int j=0; j<n-1; j++){
if (i & (1<<j)) pc++;
}
if (pc < a-1 || pc > b-1) continue;
//cout << pc << "\n";
vector<int> w;
int cur = 0;
for (int j=0; j<n; j++){
cur += v[j];
if (i & (1<<j) || j == n-1){
w.push_back(cur);
cur = 0;
}
}
int res = 0;
for (int x : w) res |= x;
//cout << i << " " << res << "\n";
bsf = min(bsf, res);
}
cout << bsf << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
8 ms |
348 KB |
Output is correct |
9 |
Correct |
7 ms |
436 KB |
Output is correct |
10 |
Correct |
7 ms |
432 KB |
Output is correct |
11 |
Correct |
7 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
91 ms |
416 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
428 KB |
Output is correct |
21 |
Correct |
13 ms |
348 KB |
Output is correct |
22 |
Correct |
13 ms |
436 KB |
Output is correct |
23 |
Correct |
13 ms |
344 KB |
Output is correct |
24 |
Correct |
7 ms |
344 KB |
Output is correct |
25 |
Correct |
13 ms |
432 KB |
Output is correct |
26 |
Correct |
77 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
436 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
432 KB |
Output is correct |
30 |
Correct |
4 ms |
348 KB |
Output is correct |
31 |
Correct |
13 ms |
348 KB |
Output is correct |
32 |
Correct |
7 ms |
348 KB |
Output is correct |
33 |
Correct |
77 ms |
412 KB |
Output is correct |
34 |
Correct |
83 ms |
348 KB |
Output is correct |
35 |
Correct |
7 ms |
344 KB |
Output is correct |
36 |
Correct |
84 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
432 KB |
Output is correct |
9 |
Correct |
7 ms |
348 KB |
Output is correct |
10 |
Correct |
7 ms |
436 KB |
Output is correct |
11 |
Correct |
7 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
85 ms |
408 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
13 ms |
348 KB |
Output is correct |
22 |
Correct |
13 ms |
348 KB |
Output is correct |
23 |
Correct |
14 ms |
348 KB |
Output is correct |
24 |
Correct |
7 ms |
436 KB |
Output is correct |
25 |
Correct |
13 ms |
432 KB |
Output is correct |
26 |
Correct |
84 ms |
412 KB |
Output is correct |
27 |
Correct |
169 ms |
344 KB |
Output is correct |
28 |
Correct |
674 ms |
408 KB |
Output is correct |
29 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
7 ms |
348 KB |
Output is correct |
9 |
Correct |
7 ms |
436 KB |
Output is correct |
10 |
Correct |
7 ms |
348 KB |
Output is correct |
11 |
Correct |
7 ms |
348 KB |
Output is correct |
12 |
Correct |
8 ms |
348 KB |
Output is correct |
13 |
Correct |
86 ms |
348 KB |
Output is correct |
14 |
Correct |
172 ms |
348 KB |
Output is correct |
15 |
Correct |
660 ms |
344 KB |
Output is correct |
16 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
432 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
7 ms |
348 KB |
Output is correct |
9 |
Correct |
8 ms |
348 KB |
Output is correct |
10 |
Correct |
7 ms |
348 KB |
Output is correct |
11 |
Correct |
8 ms |
348 KB |
Output is correct |
12 |
Correct |
9 ms |
348 KB |
Output is correct |
13 |
Correct |
101 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
13 ms |
348 KB |
Output is correct |
22 |
Correct |
13 ms |
348 KB |
Output is correct |
23 |
Correct |
13 ms |
440 KB |
Output is correct |
24 |
Correct |
8 ms |
344 KB |
Output is correct |
25 |
Correct |
13 ms |
348 KB |
Output is correct |
26 |
Correct |
83 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
512 KB |
Output is correct |
28 |
Correct |
1 ms |
344 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
3 ms |
348 KB |
Output is correct |
31 |
Correct |
13 ms |
432 KB |
Output is correct |
32 |
Correct |
7 ms |
436 KB |
Output is correct |
33 |
Correct |
83 ms |
348 KB |
Output is correct |
34 |
Correct |
83 ms |
412 KB |
Output is correct |
35 |
Correct |
7 ms |
348 KB |
Output is correct |
36 |
Correct |
84 ms |
412 KB |
Output is correct |
37 |
Correct |
189 ms |
348 KB |
Output is correct |
38 |
Correct |
667 ms |
408 KB |
Output is correct |
39 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
40 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
3 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
440 KB |
Output is correct |
8 |
Correct |
7 ms |
436 KB |
Output is correct |
9 |
Correct |
9 ms |
348 KB |
Output is correct |
10 |
Correct |
7 ms |
436 KB |
Output is correct |
11 |
Correct |
7 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
348 KB |
Output is correct |
13 |
Correct |
84 ms |
412 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
3 ms |
348 KB |
Output is correct |
18 |
Correct |
13 ms |
348 KB |
Output is correct |
19 |
Correct |
7 ms |
432 KB |
Output is correct |
20 |
Correct |
81 ms |
344 KB |
Output is correct |
21 |
Correct |
84 ms |
344 KB |
Output is correct |
22 |
Correct |
7 ms |
344 KB |
Output is correct |
23 |
Correct |
83 ms |
412 KB |
Output is correct |
24 |
Correct |
188 ms |
344 KB |
Output is correct |
25 |
Correct |
678 ms |
348 KB |
Output is correct |
26 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |