/* :) */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, A, B, ans = 0;
cin>>n>>A>>B;
ll a[n+1];
for (ll i = 1; i<=n; i++){
cin>>a[i];
ans += a[i];
}
for (ll i = 0; i<(1<<(n-1)); i++){
ll m = i, sum = 0, res = 0, cnt = 0;
for (ll j = 1; j<=n-1; j++){
if (m%2==1){
sum += a[j];
res |= sum;
sum = 0;
cnt++;
}
else {
sum += a[j];
}
m /= 2;
}
sum += a[n];
res |= sum;
cnt++;
if (cnt>=A and cnt<=B){
ans = min(ans, res);
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
356 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
452 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
460 KB |
Output is correct |
8 |
Correct |
31 ms |
348 KB |
Output is correct |
9 |
Correct |
31 ms |
348 KB |
Output is correct |
10 |
Correct |
31 ms |
344 KB |
Output is correct |
11 |
Correct |
31 ms |
348 KB |
Output is correct |
12 |
Correct |
31 ms |
344 KB |
Output is correct |
13 |
Correct |
31 ms |
436 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 |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
460 KB |
Output is correct |
20 |
Correct |
4 ms |
348 KB |
Output is correct |
21 |
Correct |
30 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
348 KB |
Output is correct |
23 |
Correct |
30 ms |
348 KB |
Output is correct |
24 |
Correct |
31 ms |
344 KB |
Output is correct |
25 |
Correct |
30 ms |
348 KB |
Output is correct |
26 |
Correct |
30 ms |
344 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
452 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
15 ms |
348 KB |
Output is correct |
31 |
Correct |
29 ms |
456 KB |
Output is correct |
32 |
Correct |
31 ms |
456 KB |
Output is correct |
33 |
Correct |
29 ms |
344 KB |
Output is correct |
34 |
Correct |
31 ms |
348 KB |
Output is correct |
35 |
Correct |
31 ms |
348 KB |
Output is correct |
36 |
Correct |
31 ms |
456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Correct |
31 ms |
348 KB |
Output is correct |
9 |
Correct |
31 ms |
348 KB |
Output is correct |
10 |
Correct |
31 ms |
452 KB |
Output is correct |
11 |
Correct |
32 ms |
348 KB |
Output is correct |
12 |
Correct |
34 ms |
348 KB |
Output is correct |
13 |
Correct |
31 ms |
348 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 |
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 |
348 KB |
Output is correct |
20 |
Correct |
4 ms |
460 KB |
Output is correct |
21 |
Correct |
30 ms |
348 KB |
Output is correct |
22 |
Correct |
29 ms |
348 KB |
Output is correct |
23 |
Correct |
30 ms |
344 KB |
Output is correct |
24 |
Correct |
31 ms |
428 KB |
Output is correct |
25 |
Correct |
29 ms |
344 KB |
Output is correct |
26 |
Correct |
30 ms |
348 KB |
Output is correct |
27 |
Correct |
63 ms |
344 KB |
Output is correct |
28 |
Execution timed out |
1016 ms |
344 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 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 |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Correct |
31 ms |
452 KB |
Output is correct |
9 |
Correct |
31 ms |
344 KB |
Output is correct |
10 |
Correct |
31 ms |
348 KB |
Output is correct |
11 |
Correct |
31 ms |
504 KB |
Output is correct |
12 |
Correct |
32 ms |
348 KB |
Output is correct |
13 |
Correct |
34 ms |
604 KB |
Output is correct |
14 |
Correct |
62 ms |
344 KB |
Output is correct |
15 |
Execution timed out |
1014 ms |
448 KB |
Time limit exceeded |
16 |
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 |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
452 KB |
Output is correct |
8 |
Correct |
31 ms |
348 KB |
Output is correct |
9 |
Correct |
32 ms |
596 KB |
Output is correct |
10 |
Correct |
31 ms |
348 KB |
Output is correct |
11 |
Correct |
31 ms |
344 KB |
Output is correct |
12 |
Correct |
31 ms |
348 KB |
Output is correct |
13 |
Correct |
31 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
456 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 |
348 KB |
Output is correct |
20 |
Correct |
4 ms |
348 KB |
Output is correct |
21 |
Correct |
32 ms |
596 KB |
Output is correct |
22 |
Correct |
31 ms |
348 KB |
Output is correct |
23 |
Correct |
30 ms |
348 KB |
Output is correct |
24 |
Correct |
31 ms |
600 KB |
Output is correct |
25 |
Correct |
30 ms |
348 KB |
Output is correct |
26 |
Correct |
30 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
344 KB |
Output is correct |
30 |
Correct |
15 ms |
348 KB |
Output is correct |
31 |
Correct |
30 ms |
604 KB |
Output is correct |
32 |
Correct |
31 ms |
348 KB |
Output is correct |
33 |
Correct |
33 ms |
348 KB |
Output is correct |
34 |
Correct |
31 ms |
344 KB |
Output is correct |
35 |
Correct |
32 ms |
348 KB |
Output is correct |
36 |
Correct |
33 ms |
348 KB |
Output is correct |
37 |
Correct |
62 ms |
348 KB |
Output is correct |
38 |
Execution timed out |
1004 ms |
448 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
4 ms |
456 KB |
Output is correct |
8 |
Correct |
31 ms |
348 KB |
Output is correct |
9 |
Correct |
31 ms |
348 KB |
Output is correct |
10 |
Correct |
30 ms |
432 KB |
Output is correct |
11 |
Correct |
32 ms |
348 KB |
Output is correct |
12 |
Correct |
31 ms |
348 KB |
Output is correct |
13 |
Correct |
31 ms |
428 KB |
Output is correct |
14 |
Correct |
1 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 |
16 ms |
600 KB |
Output is correct |
18 |
Correct |
34 ms |
348 KB |
Output is correct |
19 |
Correct |
31 ms |
344 KB |
Output is correct |
20 |
Correct |
32 ms |
348 KB |
Output is correct |
21 |
Correct |
31 ms |
448 KB |
Output is correct |
22 |
Correct |
31 ms |
428 KB |
Output is correct |
23 |
Correct |
31 ms |
348 KB |
Output is correct |
24 |
Correct |
63 ms |
432 KB |
Output is correct |
25 |
Execution timed out |
1033 ms |
544 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |