#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const long long INF = 1e15;
const int MAX = 25;
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);
}
while (d[j][i].size() > MAX) {
d[j][i].erase(--d[j][i].end());
}
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");
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
2 ms |
472 KB |
Output is correct |
4 |
Correct |
2 ms |
472 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
624 KB |
Output is correct |
7 |
Correct |
2 ms |
624 KB |
Output is correct |
8 |
Correct |
2 ms |
624 KB |
Output is correct |
9 |
Correct |
2 ms |
624 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
11 |
Correct |
2 ms |
624 KB |
Output is correct |
12 |
Correct |
2 ms |
624 KB |
Output is correct |
13 |
Correct |
2 ms |
624 KB |
Output is correct |
14 |
Correct |
2 ms |
624 KB |
Output is correct |
15 |
Correct |
2 ms |
624 KB |
Output is correct |
16 |
Correct |
2 ms |
624 KB |
Output is correct |
17 |
Correct |
2 ms |
624 KB |
Output is correct |
18 |
Correct |
2 ms |
624 KB |
Output is correct |
19 |
Correct |
2 ms |
624 KB |
Output is correct |
20 |
Correct |
2 ms |
624 KB |
Output is correct |
21 |
Correct |
2 ms |
624 KB |
Output is correct |
22 |
Correct |
2 ms |
624 KB |
Output is correct |
23 |
Correct |
3 ms |
624 KB |
Output is correct |
24 |
Correct |
2 ms |
624 KB |
Output is correct |
25 |
Correct |
3 ms |
624 KB |
Output is correct |
26 |
Correct |
3 ms |
624 KB |
Output is correct |
27 |
Correct |
2 ms |
624 KB |
Output is correct |
28 |
Correct |
2 ms |
624 KB |
Output is correct |
29 |
Correct |
2 ms |
624 KB |
Output is correct |
30 |
Correct |
2 ms |
624 KB |
Output is correct |
31 |
Correct |
3 ms |
624 KB |
Output is correct |
32 |
Correct |
2 ms |
624 KB |
Output is correct |
33 |
Correct |
2 ms |
720 KB |
Output is correct |
34 |
Correct |
3 ms |
720 KB |
Output is correct |
35 |
Correct |
2 ms |
720 KB |
Output is correct |
36 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
720 KB |
Output is correct |
2 |
Correct |
2 ms |
720 KB |
Output is correct |
3 |
Correct |
2 ms |
720 KB |
Output is correct |
4 |
Correct |
2 ms |
720 KB |
Output is correct |
5 |
Correct |
2 ms |
720 KB |
Output is correct |
6 |
Correct |
2 ms |
720 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
720 KB |
Output is correct |
10 |
Correct |
2 ms |
720 KB |
Output is correct |
11 |
Correct |
2 ms |
720 KB |
Output is correct |
12 |
Correct |
2 ms |
720 KB |
Output is correct |
13 |
Correct |
2 ms |
720 KB |
Output is correct |
14 |
Correct |
2 ms |
720 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
720 KB |
Output is correct |
17 |
Correct |
2 ms |
720 KB |
Output is correct |
18 |
Correct |
2 ms |
720 KB |
Output is correct |
19 |
Correct |
2 ms |
720 KB |
Output is correct |
20 |
Correct |
2 ms |
720 KB |
Output is correct |
21 |
Correct |
2 ms |
720 KB |
Output is correct |
22 |
Correct |
2 ms |
720 KB |
Output is correct |
23 |
Correct |
2 ms |
720 KB |
Output is correct |
24 |
Correct |
2 ms |
720 KB |
Output is correct |
25 |
Correct |
2 ms |
720 KB |
Output is correct |
26 |
Correct |
2 ms |
720 KB |
Output is correct |
27 |
Correct |
3 ms |
720 KB |
Output is correct |
28 |
Correct |
3 ms |
764 KB |
Output is correct |
29 |
Correct |
4 ms |
764 KB |
Output is correct |
30 |
Correct |
9 ms |
1020 KB |
Output is correct |
31 |
Correct |
24 ms |
1276 KB |
Output is correct |
32 |
Correct |
12 ms |
1276 KB |
Output is correct |
33 |
Correct |
2 ms |
1276 KB |
Output is correct |
34 |
Correct |
19 ms |
1276 KB |
Output is correct |
35 |
Correct |
12 ms |
1276 KB |
Output is correct |
36 |
Correct |
10 ms |
1276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1276 KB |
Output is correct |
2 |
Correct |
2 ms |
1276 KB |
Output is correct |
3 |
Correct |
2 ms |
1276 KB |
Output is correct |
4 |
Correct |
2 ms |
1276 KB |
Output is correct |
5 |
Correct |
2 ms |
1276 KB |
Output is correct |
6 |
Correct |
2 ms |
1276 KB |
Output is correct |
7 |
Correct |
2 ms |
1276 KB |
Output is correct |
8 |
Correct |
2 ms |
1276 KB |
Output is correct |
9 |
Correct |
2 ms |
1276 KB |
Output is correct |
10 |
Correct |
2 ms |
1276 KB |
Output is correct |
11 |
Correct |
2 ms |
1276 KB |
Output is correct |
12 |
Correct |
2 ms |
1276 KB |
Output is correct |
13 |
Correct |
2 ms |
1276 KB |
Output is correct |
14 |
Correct |
2 ms |
1276 KB |
Output is correct |
15 |
Correct |
3 ms |
1276 KB |
Output is correct |
16 |
Correct |
3 ms |
1276 KB |
Output is correct |
17 |
Correct |
9 ms |
1276 KB |
Output is correct |
18 |
Correct |
18 ms |
1280 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
2 ms |
1280 KB |
Output is correct |
21 |
Correct |
15 ms |
1280 KB |
Output is correct |
22 |
Correct |
12 ms |
1280 KB |
Output is correct |
23 |
Correct |
10 ms |
1280 KB |
Output is correct |
24 |
Correct |
18 ms |
1280 KB |
Output is correct |
25 |
Correct |
21 ms |
1280 KB |
Output is correct |
26 |
Correct |
64 ms |
2116 KB |
Output is correct |
27 |
Correct |
130 ms |
3836 KB |
Output is correct |
28 |
Correct |
175 ms |
5052 KB |
Output is correct |
29 |
Correct |
155 ms |
5080 KB |
Output is correct |
30 |
Correct |
2 ms |
5080 KB |
Output is correct |
31 |
Correct |
165 ms |
5080 KB |
Output is correct |
32 |
Correct |
185 ms |
5080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5080 KB |
Output is correct |
2 |
Correct |
2 ms |
5080 KB |
Output is correct |
3 |
Correct |
2 ms |
5080 KB |
Output is correct |
4 |
Correct |
2 ms |
5080 KB |
Output is correct |
5 |
Correct |
2 ms |
5080 KB |
Output is correct |
6 |
Correct |
2 ms |
5080 KB |
Output is correct |
7 |
Correct |
2 ms |
5080 KB |
Output is correct |
8 |
Correct |
2 ms |
5080 KB |
Output is correct |
9 |
Correct |
2 ms |
5080 KB |
Output is correct |
10 |
Correct |
2 ms |
5080 KB |
Output is correct |
11 |
Correct |
2 ms |
5080 KB |
Output is correct |
12 |
Correct |
2 ms |
5080 KB |
Output is correct |
13 |
Correct |
2 ms |
5080 KB |
Output is correct |
14 |
Correct |
2 ms |
5080 KB |
Output is correct |
15 |
Correct |
2 ms |
5080 KB |
Output is correct |
16 |
Correct |
2 ms |
5080 KB |
Output is correct |
17 |
Correct |
2 ms |
5080 KB |
Output is correct |
18 |
Correct |
2 ms |
5080 KB |
Output is correct |
19 |
Correct |
2 ms |
5080 KB |
Output is correct |
20 |
Correct |
2 ms |
5080 KB |
Output is correct |
21 |
Correct |
2 ms |
5080 KB |
Output is correct |
22 |
Correct |
2 ms |
5080 KB |
Output is correct |
23 |
Correct |
2 ms |
5080 KB |
Output is correct |
24 |
Correct |
2 ms |
5080 KB |
Output is correct |
25 |
Correct |
3 ms |
5080 KB |
Output is correct |
26 |
Correct |
2 ms |
5080 KB |
Output is correct |
27 |
Correct |
2 ms |
5080 KB |
Output is correct |
28 |
Correct |
2 ms |
5080 KB |
Output is correct |
29 |
Correct |
2 ms |
5080 KB |
Output is correct |
30 |
Correct |
2 ms |
5080 KB |
Output is correct |
31 |
Correct |
2 ms |
5080 KB |
Output is correct |
32 |
Correct |
2 ms |
5080 KB |
Output is correct |
33 |
Correct |
2 ms |
5080 KB |
Output is correct |
34 |
Correct |
2 ms |
5080 KB |
Output is correct |
35 |
Correct |
2 ms |
5080 KB |
Output is correct |
36 |
Correct |
2 ms |
5080 KB |
Output is correct |
37 |
Correct |
2 ms |
5080 KB |
Output is correct |
38 |
Correct |
3 ms |
5080 KB |
Output is correct |
39 |
Correct |
3 ms |
5080 KB |
Output is correct |
40 |
Correct |
8 ms |
5080 KB |
Output is correct |
41 |
Correct |
21 ms |
5080 KB |
Output is correct |
42 |
Correct |
11 ms |
5080 KB |
Output is correct |
43 |
Correct |
2 ms |
5080 KB |
Output is correct |
44 |
Correct |
14 ms |
5080 KB |
Output is correct |
45 |
Correct |
13 ms |
5080 KB |
Output is correct |
46 |
Correct |
10 ms |
5080 KB |
Output is correct |
47 |
Correct |
20 ms |
5080 KB |
Output is correct |
48 |
Correct |
21 ms |
5080 KB |
Output is correct |
49 |
Correct |
65 ms |
5080 KB |
Output is correct |
50 |
Correct |
133 ms |
5080 KB |
Output is correct |
51 |
Correct |
182 ms |
5080 KB |
Output is correct |
52 |
Correct |
162 ms |
5116 KB |
Output is correct |
53 |
Correct |
2 ms |
5116 KB |
Output is correct |
54 |
Correct |
164 ms |
5116 KB |
Output is correct |
55 |
Correct |
178 ms |
5116 KB |
Output is correct |
56 |
Correct |
28 ms |
5116 KB |
Output is correct |
57 |
Correct |
120 ms |
5116 KB |
Output is correct |
58 |
Correct |
180 ms |
5116 KB |
Output is correct |
59 |
Correct |
240 ms |
5376 KB |
Output is correct |
60 |
Correct |
289 ms |
6024 KB |
Output is correct |
61 |
Correct |
2 ms |
6024 KB |
Output is correct |
62 |
Correct |
294 ms |
6024 KB |
Output is correct |
63 |
Correct |
300 ms |
6024 KB |
Output is correct |
64 |
Correct |
68 ms |
6024 KB |
Output is correct |
65 |
Correct |
29 ms |
6024 KB |
Output is correct |
66 |
Correct |
33 ms |
6024 KB |
Output is correct |
67 |
Correct |
110 ms |
6024 KB |
Output is correct |
68 |
Correct |
199 ms |
6024 KB |
Output is correct |
69 |
Correct |
241 ms |
6024 KB |
Output is correct |
70 |
Correct |
301 ms |
6064 KB |
Output is correct |
71 |
Correct |
2 ms |
6064 KB |
Output is correct |
72 |
Correct |
241 ms |
6064 KB |
Output is correct |
73 |
Correct |
257 ms |
6064 KB |
Output is correct |
74 |
Incorrect |
270 ms |
6064 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6064 KB |
Output is correct |
2 |
Correct |
2 ms |
6064 KB |
Output is correct |
3 |
Correct |
2 ms |
6064 KB |
Output is correct |
4 |
Correct |
2 ms |
6064 KB |
Output is correct |
5 |
Correct |
2 ms |
6064 KB |
Output is correct |
6 |
Correct |
2 ms |
6064 KB |
Output is correct |
7 |
Correct |
2 ms |
6064 KB |
Output is correct |
8 |
Correct |
2 ms |
6064 KB |
Output is correct |
9 |
Correct |
2 ms |
6064 KB |
Output is correct |
10 |
Correct |
2 ms |
6064 KB |
Output is correct |
11 |
Correct |
2 ms |
6064 KB |
Output is correct |
12 |
Correct |
2 ms |
6064 KB |
Output is correct |
13 |
Correct |
2 ms |
6064 KB |
Output is correct |
14 |
Correct |
2 ms |
6064 KB |
Output is correct |
15 |
Correct |
2 ms |
6064 KB |
Output is correct |
16 |
Correct |
2 ms |
6064 KB |
Output is correct |
17 |
Correct |
2 ms |
6064 KB |
Output is correct |
18 |
Correct |
2 ms |
6064 KB |
Output is correct |
19 |
Correct |
2 ms |
6064 KB |
Output is correct |
20 |
Correct |
2 ms |
6064 KB |
Output is correct |
21 |
Correct |
2 ms |
6064 KB |
Output is correct |
22 |
Correct |
2 ms |
6064 KB |
Output is correct |
23 |
Correct |
2 ms |
6064 KB |
Output is correct |
24 |
Correct |
2 ms |
6064 KB |
Output is correct |
25 |
Correct |
3 ms |
6064 KB |
Output is correct |
26 |
Correct |
3 ms |
6064 KB |
Output is correct |
27 |
Correct |
8 ms |
6064 KB |
Output is correct |
28 |
Correct |
18 ms |
6064 KB |
Output is correct |
29 |
Correct |
12 ms |
6064 KB |
Output is correct |
30 |
Correct |
2 ms |
6064 KB |
Output is correct |
31 |
Correct |
14 ms |
6064 KB |
Output is correct |
32 |
Correct |
12 ms |
6064 KB |
Output is correct |
33 |
Correct |
10 ms |
6064 KB |
Output is correct |
34 |
Correct |
18 ms |
6064 KB |
Output is correct |
35 |
Correct |
20 ms |
6064 KB |
Output is correct |
36 |
Correct |
62 ms |
6064 KB |
Output is correct |
37 |
Correct |
130 ms |
6064 KB |
Output is correct |
38 |
Correct |
179 ms |
6064 KB |
Output is correct |
39 |
Correct |
156 ms |
6064 KB |
Output is correct |
40 |
Correct |
2 ms |
6064 KB |
Output is correct |
41 |
Correct |
169 ms |
6064 KB |
Output is correct |
42 |
Correct |
182 ms |
6064 KB |
Output is correct |
43 |
Correct |
27 ms |
6064 KB |
Output is correct |
44 |
Correct |
88 ms |
6064 KB |
Output is correct |
45 |
Correct |
184 ms |
6064 KB |
Output is correct |
46 |
Correct |
232 ms |
6064 KB |
Output is correct |
47 |
Correct |
288 ms |
6064 KB |
Output is correct |
48 |
Correct |
2 ms |
6064 KB |
Output is correct |
49 |
Correct |
260 ms |
6064 KB |
Output is correct |
50 |
Correct |
253 ms |
6064 KB |
Output is correct |
51 |
Correct |
158 ms |
6064 KB |
Output is correct |
52 |
Execution timed out |
1076 ms |
6064 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |