#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll subtask1(int n, int l, int r)
{
ll ans = (1LL << 60);
vector <int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
for (int mask = 1; mask < (1 << n); mask += 2)
{
int bits = 0, aux = mask;
while (aux)
{
bits++;
aux -= aux & (-aux);
}
if (l <= bits && bits <= r)
{
ll curs = 0, cur = 0;
for (int i = 0; i < n; i++)
{
if (mask & (1 << i))
{
cur |= curs;
curs = 0;
}
curs += a[i];
}
cur |= curs;
ans = min(ans, cur);
}
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
/// freopen ("input", "r", stdin);
int n, l, r;
cin >> n >> l >> r;
if (n <= 20)
{
cout << subtask1(n, l, r) << "\n";
return 0;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
416 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
504 KB |
Output is correct |
12 |
Correct |
7 ms |
376 KB |
Output is correct |
13 |
Correct |
46 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
9 ms |
376 KB |
Output is correct |
22 |
Correct |
10 ms |
376 KB |
Output is correct |
23 |
Correct |
10 ms |
416 KB |
Output is correct |
24 |
Correct |
7 ms |
376 KB |
Output is correct |
25 |
Correct |
10 ms |
404 KB |
Output is correct |
26 |
Correct |
42 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
10 ms |
376 KB |
Output is correct |
32 |
Correct |
7 ms |
376 KB |
Output is correct |
33 |
Correct |
42 ms |
376 KB |
Output is correct |
34 |
Correct |
45 ms |
376 KB |
Output is correct |
35 |
Correct |
7 ms |
376 KB |
Output is correct |
36 |
Correct |
45 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
376 KB |
Output is correct |
12 |
Correct |
7 ms |
380 KB |
Output is correct |
13 |
Correct |
45 ms |
380 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
10 ms |
376 KB |
Output is correct |
22 |
Correct |
9 ms |
376 KB |
Output is correct |
23 |
Correct |
10 ms |
376 KB |
Output is correct |
24 |
Correct |
7 ms |
376 KB |
Output is correct |
25 |
Correct |
10 ms |
376 KB |
Output is correct |
26 |
Correct |
43 ms |
376 KB |
Output is correct |
27 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
376 KB |
Output is correct |
12 |
Correct |
7 ms |
376 KB |
Output is correct |
13 |
Correct |
45 ms |
376 KB |
Output is correct |
14 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
380 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
412 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
45 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
10 ms |
376 KB |
Output is correct |
22 |
Correct |
9 ms |
376 KB |
Output is correct |
23 |
Correct |
9 ms |
376 KB |
Output is correct |
24 |
Correct |
6 ms |
376 KB |
Output is correct |
25 |
Correct |
10 ms |
376 KB |
Output is correct |
26 |
Correct |
42 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
4 ms |
376 KB |
Output is correct |
31 |
Correct |
10 ms |
380 KB |
Output is correct |
32 |
Correct |
8 ms |
376 KB |
Output is correct |
33 |
Correct |
42 ms |
376 KB |
Output is correct |
34 |
Correct |
86 ms |
376 KB |
Output is correct |
35 |
Correct |
6 ms |
376 KB |
Output is correct |
36 |
Correct |
45 ms |
376 KB |
Output is correct |
37 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
7 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
376 KB |
Output is correct |
10 |
Correct |
7 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
7 ms |
376 KB |
Output is correct |
13 |
Correct |
45 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
4 ms |
376 KB |
Output is correct |
18 |
Correct |
10 ms |
380 KB |
Output is correct |
19 |
Correct |
7 ms |
376 KB |
Output is correct |
20 |
Correct |
42 ms |
376 KB |
Output is correct |
21 |
Correct |
45 ms |
376 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
48 ms |
376 KB |
Output is correct |
24 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |