#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
#define inf 1000000000000000000
vi Y;
ll n,a,b;
ll cnt(ll m){
ll ans = 0;
while(m > 0){
ans += m%2;
m /= 2;
}
return ans;
}
int main(){
cin >> n >> a >> b;
Y.assign(n,0);
rep(i,0,n) cin >> Y[i];
if (n > 20) exit(0);
ll best = inf,cur;
rep(x,0,(1<<(n-1))){
ll X = cnt(x); X++;
cur = 0;
if (X > b || X < a) continue;
ll t = x,last = 0;
rep(i,1,n){
if (t%2){
ll temp = 0;
rep(j,last,i) temp += Y[j];
cur |= temp;
last = i;
}
t /= 2;
}
ll temp = 0;
rep(j,last,n) temp += Y[j];
cur |= temp;
best = min(best,cur);
}
cout << best << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
360 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
3 ms |
444 KB |
Output is correct |
6 |
Correct |
5 ms |
520 KB |
Output is correct |
7 |
Correct |
4 ms |
656 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
10 ms |
772 KB |
Output is correct |
10 |
Correct |
12 ms |
772 KB |
Output is correct |
11 |
Correct |
11 ms |
772 KB |
Output is correct |
12 |
Correct |
10 ms |
772 KB |
Output is correct |
13 |
Correct |
59 ms |
772 KB |
Output is correct |
14 |
Correct |
3 ms |
856 KB |
Output is correct |
15 |
Correct |
3 ms |
856 KB |
Output is correct |
16 |
Correct |
4 ms |
856 KB |
Output is correct |
17 |
Correct |
2 ms |
856 KB |
Output is correct |
18 |
Correct |
3 ms |
856 KB |
Output is correct |
19 |
Correct |
3 ms |
856 KB |
Output is correct |
20 |
Correct |
3 ms |
856 KB |
Output is correct |
21 |
Correct |
18 ms |
856 KB |
Output is correct |
22 |
Correct |
16 ms |
856 KB |
Output is correct |
23 |
Correct |
19 ms |
856 KB |
Output is correct |
24 |
Correct |
12 ms |
856 KB |
Output is correct |
25 |
Correct |
17 ms |
856 KB |
Output is correct |
26 |
Correct |
60 ms |
856 KB |
Output is correct |
27 |
Correct |
2 ms |
856 KB |
Output is correct |
28 |
Correct |
3 ms |
856 KB |
Output is correct |
29 |
Correct |
4 ms |
856 KB |
Output is correct |
30 |
Correct |
9 ms |
856 KB |
Output is correct |
31 |
Correct |
16 ms |
856 KB |
Output is correct |
32 |
Correct |
12 ms |
856 KB |
Output is correct |
33 |
Correct |
57 ms |
856 KB |
Output is correct |
34 |
Correct |
65 ms |
856 KB |
Output is correct |
35 |
Correct |
13 ms |
856 KB |
Output is correct |
36 |
Correct |
59 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
3 ms |
856 KB |
Output is correct |
3 |
Correct |
3 ms |
856 KB |
Output is correct |
4 |
Correct |
3 ms |
864 KB |
Output is correct |
5 |
Correct |
3 ms |
864 KB |
Output is correct |
6 |
Correct |
5 ms |
864 KB |
Output is correct |
7 |
Correct |
4 ms |
864 KB |
Output is correct |
8 |
Correct |
11 ms |
864 KB |
Output is correct |
9 |
Correct |
12 ms |
864 KB |
Output is correct |
10 |
Correct |
14 ms |
896 KB |
Output is correct |
11 |
Correct |
12 ms |
896 KB |
Output is correct |
12 |
Correct |
15 ms |
908 KB |
Output is correct |
13 |
Correct |
59 ms |
920 KB |
Output is correct |
14 |
Correct |
2 ms |
920 KB |
Output is correct |
15 |
Correct |
3 ms |
920 KB |
Output is correct |
16 |
Correct |
2 ms |
920 KB |
Output is correct |
17 |
Correct |
2 ms |
920 KB |
Output is correct |
18 |
Correct |
3 ms |
920 KB |
Output is correct |
19 |
Correct |
3 ms |
920 KB |
Output is correct |
20 |
Correct |
5 ms |
920 KB |
Output is correct |
21 |
Correct |
18 ms |
920 KB |
Output is correct |
22 |
Correct |
18 ms |
920 KB |
Output is correct |
23 |
Correct |
15 ms |
920 KB |
Output is correct |
24 |
Correct |
10 ms |
920 KB |
Output is correct |
25 |
Correct |
15 ms |
920 KB |
Output is correct |
26 |
Correct |
64 ms |
920 KB |
Output is correct |
27 |
Incorrect |
3 ms |
920 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
920 KB |
Output is correct |
2 |
Correct |
2 ms |
920 KB |
Output is correct |
3 |
Correct |
3 ms |
920 KB |
Output is correct |
4 |
Correct |
3 ms |
920 KB |
Output is correct |
5 |
Correct |
3 ms |
920 KB |
Output is correct |
6 |
Correct |
5 ms |
920 KB |
Output is correct |
7 |
Correct |
4 ms |
920 KB |
Output is correct |
8 |
Correct |
14 ms |
920 KB |
Output is correct |
9 |
Correct |
13 ms |
920 KB |
Output is correct |
10 |
Correct |
12 ms |
920 KB |
Output is correct |
11 |
Correct |
14 ms |
920 KB |
Output is correct |
12 |
Correct |
12 ms |
920 KB |
Output is correct |
13 |
Correct |
61 ms |
920 KB |
Output is correct |
14 |
Incorrect |
3 ms |
920 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
920 KB |
Output is correct |
2 |
Correct |
3 ms |
920 KB |
Output is correct |
3 |
Correct |
2 ms |
920 KB |
Output is correct |
4 |
Correct |
2 ms |
920 KB |
Output is correct |
5 |
Correct |
4 ms |
920 KB |
Output is correct |
6 |
Correct |
5 ms |
920 KB |
Output is correct |
7 |
Correct |
4 ms |
920 KB |
Output is correct |
8 |
Correct |
13 ms |
920 KB |
Output is correct |
9 |
Correct |
11 ms |
920 KB |
Output is correct |
10 |
Correct |
13 ms |
920 KB |
Output is correct |
11 |
Correct |
13 ms |
920 KB |
Output is correct |
12 |
Correct |
11 ms |
920 KB |
Output is correct |
13 |
Correct |
63 ms |
920 KB |
Output is correct |
14 |
Correct |
2 ms |
920 KB |
Output is correct |
15 |
Correct |
2 ms |
920 KB |
Output is correct |
16 |
Correct |
3 ms |
920 KB |
Output is correct |
17 |
Correct |
2 ms |
920 KB |
Output is correct |
18 |
Correct |
2 ms |
920 KB |
Output is correct |
19 |
Correct |
3 ms |
920 KB |
Output is correct |
20 |
Correct |
4 ms |
920 KB |
Output is correct |
21 |
Correct |
21 ms |
920 KB |
Output is correct |
22 |
Correct |
18 ms |
920 KB |
Output is correct |
23 |
Correct |
22 ms |
920 KB |
Output is correct |
24 |
Correct |
10 ms |
920 KB |
Output is correct |
25 |
Correct |
20 ms |
920 KB |
Output is correct |
26 |
Correct |
61 ms |
924 KB |
Output is correct |
27 |
Correct |
3 ms |
924 KB |
Output is correct |
28 |
Correct |
3 ms |
924 KB |
Output is correct |
29 |
Correct |
3 ms |
924 KB |
Output is correct |
30 |
Correct |
7 ms |
924 KB |
Output is correct |
31 |
Correct |
15 ms |
924 KB |
Output is correct |
32 |
Correct |
20 ms |
924 KB |
Output is correct |
33 |
Correct |
64 ms |
924 KB |
Output is correct |
34 |
Correct |
61 ms |
924 KB |
Output is correct |
35 |
Correct |
13 ms |
924 KB |
Output is correct |
36 |
Correct |
63 ms |
924 KB |
Output is correct |
37 |
Incorrect |
2 ms |
924 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
924 KB |
Output is correct |
2 |
Correct |
3 ms |
924 KB |
Output is correct |
3 |
Correct |
3 ms |
924 KB |
Output is correct |
4 |
Correct |
3 ms |
924 KB |
Output is correct |
5 |
Correct |
4 ms |
924 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
4 ms |
928 KB |
Output is correct |
8 |
Correct |
11 ms |
928 KB |
Output is correct |
9 |
Correct |
20 ms |
928 KB |
Output is correct |
10 |
Correct |
13 ms |
928 KB |
Output is correct |
11 |
Correct |
11 ms |
928 KB |
Output is correct |
12 |
Correct |
12 ms |
928 KB |
Output is correct |
13 |
Correct |
61 ms |
960 KB |
Output is correct |
14 |
Correct |
3 ms |
976 KB |
Output is correct |
15 |
Correct |
3 ms |
976 KB |
Output is correct |
16 |
Correct |
3 ms |
976 KB |
Output is correct |
17 |
Correct |
11 ms |
976 KB |
Output is correct |
18 |
Correct |
16 ms |
976 KB |
Output is correct |
19 |
Correct |
14 ms |
976 KB |
Output is correct |
20 |
Correct |
56 ms |
1000 KB |
Output is correct |
21 |
Correct |
77 ms |
1000 KB |
Output is correct |
22 |
Correct |
11 ms |
1000 KB |
Output is correct |
23 |
Correct |
67 ms |
1000 KB |
Output is correct |
24 |
Incorrect |
2 ms |
1000 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |