#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const long long INF = 1e15;
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, a, b;
cin >> n >> a >> b;
vector<long long> x(n + 1);
for (int i = 1; i <= n; i++) {
cin >> x[i];
}
vector<vector<set<long long>>> d(b + 1, vector<set<long long>>(n + 1));
d[0][0].insert(0);
for (int j = 1; j <= b; j++) {
for (int i = 1; i <= n; i++) {
long long cur = x[i];
for (int k = i - 1; k >= 0; k--) {
for (auto &x : d[j - 1][k]) {
d[j][i].insert(cur | x);
}
cur += x[k];
}
}
}
long long ans = INF;
for (int i = a; i <= b; i++) {
ans = min(ans, *d[i][n].begin());
}
cout << ans << endl;
/// system("pause");
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
2 ms |
444 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
2 ms |
552 KB |
Output is correct |
8 |
Correct |
2 ms |
552 KB |
Output is correct |
9 |
Correct |
2 ms |
552 KB |
Output is correct |
10 |
Correct |
2 ms |
552 KB |
Output is correct |
11 |
Correct |
2 ms |
552 KB |
Output is correct |
12 |
Correct |
2 ms |
728 KB |
Output is correct |
13 |
Correct |
2 ms |
728 KB |
Output is correct |
14 |
Correct |
2 ms |
728 KB |
Output is correct |
15 |
Correct |
2 ms |
728 KB |
Output is correct |
16 |
Correct |
2 ms |
728 KB |
Output is correct |
17 |
Correct |
2 ms |
728 KB |
Output is correct |
18 |
Correct |
2 ms |
728 KB |
Output is correct |
19 |
Correct |
2 ms |
728 KB |
Output is correct |
20 |
Correct |
2 ms |
728 KB |
Output is correct |
21 |
Correct |
2 ms |
728 KB |
Output is correct |
22 |
Correct |
2 ms |
728 KB |
Output is correct |
23 |
Correct |
2 ms |
728 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
3 ms |
772 KB |
Output is correct |
26 |
Correct |
2 ms |
772 KB |
Output is correct |
27 |
Correct |
2 ms |
772 KB |
Output is correct |
28 |
Correct |
2 ms |
772 KB |
Output is correct |
29 |
Correct |
3 ms |
772 KB |
Output is correct |
30 |
Correct |
3 ms |
772 KB |
Output is correct |
31 |
Correct |
2 ms |
832 KB |
Output is correct |
32 |
Correct |
2 ms |
832 KB |
Output is correct |
33 |
Correct |
2 ms |
832 KB |
Output is correct |
34 |
Correct |
2 ms |
832 KB |
Output is correct |
35 |
Correct |
2 ms |
832 KB |
Output is correct |
36 |
Correct |
2 ms |
832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
832 KB |
Output is correct |
2 |
Correct |
2 ms |
832 KB |
Output is correct |
3 |
Correct |
2 ms |
832 KB |
Output is correct |
4 |
Correct |
2 ms |
832 KB |
Output is correct |
5 |
Correct |
2 ms |
900 KB |
Output is correct |
6 |
Correct |
2 ms |
900 KB |
Output is correct |
7 |
Correct |
2 ms |
900 KB |
Output is correct |
8 |
Correct |
2 ms |
900 KB |
Output is correct |
9 |
Correct |
2 ms |
900 KB |
Output is correct |
10 |
Correct |
2 ms |
900 KB |
Output is correct |
11 |
Correct |
2 ms |
900 KB |
Output is correct |
12 |
Correct |
2 ms |
900 KB |
Output is correct |
13 |
Correct |
3 ms |
900 KB |
Output is correct |
14 |
Correct |
2 ms |
900 KB |
Output is correct |
15 |
Correct |
2 ms |
900 KB |
Output is correct |
16 |
Correct |
2 ms |
900 KB |
Output is correct |
17 |
Correct |
2 ms |
900 KB |
Output is correct |
18 |
Correct |
2 ms |
900 KB |
Output is correct |
19 |
Correct |
2 ms |
900 KB |
Output is correct |
20 |
Correct |
2 ms |
900 KB |
Output is correct |
21 |
Correct |
2 ms |
900 KB |
Output is correct |
22 |
Correct |
2 ms |
900 KB |
Output is correct |
23 |
Correct |
2 ms |
900 KB |
Output is correct |
24 |
Correct |
2 ms |
900 KB |
Output is correct |
25 |
Correct |
2 ms |
900 KB |
Output is correct |
26 |
Correct |
2 ms |
900 KB |
Output is correct |
27 |
Correct |
3 ms |
900 KB |
Output is correct |
28 |
Correct |
3 ms |
904 KB |
Output is correct |
29 |
Correct |
4 ms |
1008 KB |
Output is correct |
30 |
Correct |
10 ms |
1396 KB |
Output is correct |
31 |
Correct |
23 ms |
2056 KB |
Output is correct |
32 |
Correct |
11 ms |
2056 KB |
Output is correct |
33 |
Correct |
2 ms |
2056 KB |
Output is correct |
34 |
Correct |
15 ms |
2056 KB |
Output is correct |
35 |
Correct |
14 ms |
2056 KB |
Output is correct |
36 |
Correct |
12 ms |
2056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2056 KB |
Output is correct |
2 |
Correct |
2 ms |
2056 KB |
Output is correct |
3 |
Correct |
2 ms |
2056 KB |
Output is correct |
4 |
Correct |
2 ms |
2056 KB |
Output is correct |
5 |
Correct |
2 ms |
2056 KB |
Output is correct |
6 |
Correct |
2 ms |
2056 KB |
Output is correct |
7 |
Correct |
2 ms |
2056 KB |
Output is correct |
8 |
Correct |
2 ms |
2056 KB |
Output is correct |
9 |
Correct |
2 ms |
2056 KB |
Output is correct |
10 |
Correct |
2 ms |
2056 KB |
Output is correct |
11 |
Correct |
2 ms |
2056 KB |
Output is correct |
12 |
Correct |
2 ms |
2056 KB |
Output is correct |
13 |
Correct |
2 ms |
2056 KB |
Output is correct |
14 |
Correct |
2 ms |
2056 KB |
Output is correct |
15 |
Correct |
3 ms |
2056 KB |
Output is correct |
16 |
Correct |
4 ms |
2056 KB |
Output is correct |
17 |
Correct |
9 ms |
2056 KB |
Output is correct |
18 |
Correct |
22 ms |
2124 KB |
Output is correct |
19 |
Correct |
11 ms |
2124 KB |
Output is correct |
20 |
Correct |
2 ms |
2124 KB |
Output is correct |
21 |
Correct |
15 ms |
2124 KB |
Output is correct |
22 |
Correct |
14 ms |
2124 KB |
Output is correct |
23 |
Correct |
12 ms |
2124 KB |
Output is correct |
24 |
Correct |
26 ms |
2312 KB |
Output is correct |
25 |
Correct |
39 ms |
2536 KB |
Output is correct |
26 |
Correct |
136 ms |
5668 KB |
Output is correct |
27 |
Correct |
246 ms |
9328 KB |
Output is correct |
28 |
Correct |
355 ms |
12404 KB |
Output is correct |
29 |
Correct |
214 ms |
12404 KB |
Output is correct |
30 |
Correct |
2 ms |
12404 KB |
Output is correct |
31 |
Correct |
418 ms |
13184 KB |
Output is correct |
32 |
Correct |
431 ms |
14124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14124 KB |
Output is correct |
2 |
Correct |
2 ms |
14124 KB |
Output is correct |
3 |
Correct |
2 ms |
14124 KB |
Output is correct |
4 |
Correct |
2 ms |
14124 KB |
Output is correct |
5 |
Correct |
2 ms |
14124 KB |
Output is correct |
6 |
Correct |
2 ms |
14124 KB |
Output is correct |
7 |
Correct |
2 ms |
14124 KB |
Output is correct |
8 |
Correct |
2 ms |
14124 KB |
Output is correct |
9 |
Correct |
2 ms |
14124 KB |
Output is correct |
10 |
Correct |
2 ms |
14124 KB |
Output is correct |
11 |
Correct |
2 ms |
14124 KB |
Output is correct |
12 |
Correct |
2 ms |
14124 KB |
Output is correct |
13 |
Correct |
2 ms |
14124 KB |
Output is correct |
14 |
Correct |
2 ms |
14124 KB |
Output is correct |
15 |
Correct |
2 ms |
14124 KB |
Output is correct |
16 |
Correct |
2 ms |
14124 KB |
Output is correct |
17 |
Correct |
2 ms |
14124 KB |
Output is correct |
18 |
Correct |
2 ms |
14124 KB |
Output is correct |
19 |
Correct |
2 ms |
14124 KB |
Output is correct |
20 |
Correct |
2 ms |
14124 KB |
Output is correct |
21 |
Correct |
2 ms |
14124 KB |
Output is correct |
22 |
Correct |
3 ms |
14124 KB |
Output is correct |
23 |
Correct |
2 ms |
14124 KB |
Output is correct |
24 |
Correct |
2 ms |
14124 KB |
Output is correct |
25 |
Correct |
2 ms |
14124 KB |
Output is correct |
26 |
Correct |
3 ms |
14124 KB |
Output is correct |
27 |
Correct |
2 ms |
14124 KB |
Output is correct |
28 |
Correct |
2 ms |
14124 KB |
Output is correct |
29 |
Correct |
2 ms |
14124 KB |
Output is correct |
30 |
Correct |
2 ms |
14124 KB |
Output is correct |
31 |
Correct |
2 ms |
14124 KB |
Output is correct |
32 |
Correct |
2 ms |
14124 KB |
Output is correct |
33 |
Correct |
2 ms |
14124 KB |
Output is correct |
34 |
Correct |
2 ms |
14124 KB |
Output is correct |
35 |
Correct |
2 ms |
14124 KB |
Output is correct |
36 |
Correct |
2 ms |
14124 KB |
Output is correct |
37 |
Correct |
2 ms |
14124 KB |
Output is correct |
38 |
Correct |
3 ms |
14124 KB |
Output is correct |
39 |
Correct |
3 ms |
14124 KB |
Output is correct |
40 |
Correct |
9 ms |
14124 KB |
Output is correct |
41 |
Correct |
22 ms |
14124 KB |
Output is correct |
42 |
Correct |
11 ms |
14124 KB |
Output is correct |
43 |
Correct |
2 ms |
14124 KB |
Output is correct |
44 |
Correct |
15 ms |
14124 KB |
Output is correct |
45 |
Correct |
14 ms |
14124 KB |
Output is correct |
46 |
Correct |
12 ms |
14124 KB |
Output is correct |
47 |
Correct |
25 ms |
14124 KB |
Output is correct |
48 |
Correct |
38 ms |
14124 KB |
Output is correct |
49 |
Correct |
131 ms |
14124 KB |
Output is correct |
50 |
Correct |
244 ms |
14124 KB |
Output is correct |
51 |
Correct |
356 ms |
14124 KB |
Output is correct |
52 |
Correct |
209 ms |
14124 KB |
Output is correct |
53 |
Correct |
2 ms |
14124 KB |
Output is correct |
54 |
Correct |
412 ms |
14124 KB |
Output is correct |
55 |
Correct |
435 ms |
14424 KB |
Output is correct |
56 |
Correct |
675 ms |
36276 KB |
Output is correct |
57 |
Execution timed out |
1092 ms |
54496 KB |
Time limit exceeded |
58 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
54496 KB |
Output is correct |
2 |
Correct |
2 ms |
54496 KB |
Output is correct |
3 |
Correct |
2 ms |
54496 KB |
Output is correct |
4 |
Correct |
2 ms |
54496 KB |
Output is correct |
5 |
Correct |
2 ms |
54496 KB |
Output is correct |
6 |
Correct |
2 ms |
54496 KB |
Output is correct |
7 |
Correct |
2 ms |
54496 KB |
Output is correct |
8 |
Correct |
3 ms |
54496 KB |
Output is correct |
9 |
Correct |
2 ms |
54496 KB |
Output is correct |
10 |
Correct |
3 ms |
54496 KB |
Output is correct |
11 |
Correct |
2 ms |
54496 KB |
Output is correct |
12 |
Correct |
3 ms |
54496 KB |
Output is correct |
13 |
Correct |
3 ms |
54496 KB |
Output is correct |
14 |
Correct |
3 ms |
54496 KB |
Output is correct |
15 |
Correct |
2 ms |
54496 KB |
Output is correct |
16 |
Correct |
3 ms |
54496 KB |
Output is correct |
17 |
Correct |
2 ms |
54496 KB |
Output is correct |
18 |
Correct |
2 ms |
54496 KB |
Output is correct |
19 |
Correct |
2 ms |
54496 KB |
Output is correct |
20 |
Correct |
3 ms |
54496 KB |
Output is correct |
21 |
Correct |
2 ms |
54496 KB |
Output is correct |
22 |
Correct |
3 ms |
54496 KB |
Output is correct |
23 |
Correct |
3 ms |
54496 KB |
Output is correct |
24 |
Correct |
3 ms |
54496 KB |
Output is correct |
25 |
Correct |
3 ms |
54496 KB |
Output is correct |
26 |
Correct |
4 ms |
54496 KB |
Output is correct |
27 |
Correct |
9 ms |
54496 KB |
Output is correct |
28 |
Correct |
22 ms |
54496 KB |
Output is correct |
29 |
Correct |
11 ms |
54496 KB |
Output is correct |
30 |
Correct |
2 ms |
54496 KB |
Output is correct |
31 |
Correct |
15 ms |
54496 KB |
Output is correct |
32 |
Correct |
14 ms |
54496 KB |
Output is correct |
33 |
Correct |
12 ms |
54496 KB |
Output is correct |
34 |
Correct |
25 ms |
54496 KB |
Output is correct |
35 |
Correct |
38 ms |
54496 KB |
Output is correct |
36 |
Correct |
132 ms |
54496 KB |
Output is correct |
37 |
Correct |
247 ms |
54496 KB |
Output is correct |
38 |
Correct |
364 ms |
54496 KB |
Output is correct |
39 |
Correct |
215 ms |
54496 KB |
Output is correct |
40 |
Correct |
2 ms |
54496 KB |
Output is correct |
41 |
Correct |
404 ms |
54496 KB |
Output is correct |
42 |
Correct |
429 ms |
54496 KB |
Output is correct |
43 |
Correct |
706 ms |
54496 KB |
Output is correct |
44 |
Execution timed out |
1074 ms |
54496 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |