#include <bits/stdc++.h>
using namespace std;
#define v vector
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define on(i,mask) ((bool)((1<<(i)) & (mask)))
int main(){
int N,A,B;
cin>>N>>A>>B;
v<ll> Y(N+1,0);
v<ll> psum(N+1, 0);
for(int i=1; i<=N; i++){
cin>>Y[i];
psum[i] = psum[i-1]+Y[i];
}
if(N<=20){
ll ans = 1e18;
for(int div = (1<<N); div<(1<<(N+1)); div++){
int g = 1;
int l=0;
ll res = 0;
for(int i=1; i<=N; i++){
if(i!=1 && on(i-2,div)!=on(i-1,div)){
g++;
res = res | (psum[i-1] - psum[l]);
l=i-1;
}
}
res = res | (psum[N]-psum[l]);
if(A<=g && g<=B) ans = min(ans, res);
}
cout<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
8 |
Correct |
72 ms |
348 KB |
Output is correct |
9 |
Correct |
72 ms |
344 KB |
Output is correct |
10 |
Correct |
70 ms |
348 KB |
Output is correct |
11 |
Correct |
70 ms |
348 KB |
Output is correct |
12 |
Correct |
73 ms |
416 KB |
Output is correct |
13 |
Correct |
67 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
8 ms |
348 KB |
Output is correct |
21 |
Correct |
65 ms |
408 KB |
Output is correct |
22 |
Correct |
67 ms |
348 KB |
Output is correct |
23 |
Correct |
65 ms |
344 KB |
Output is correct |
24 |
Correct |
73 ms |
348 KB |
Output is correct |
25 |
Correct |
67 ms |
348 KB |
Output is correct |
26 |
Correct |
64 ms |
412 KB |
Output is correct |
27 |
Correct |
0 ms |
344 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
34 ms |
436 KB |
Output is correct |
31 |
Correct |
66 ms |
344 KB |
Output is correct |
32 |
Correct |
71 ms |
344 KB |
Output is correct |
33 |
Correct |
65 ms |
348 KB |
Output is correct |
34 |
Correct |
68 ms |
344 KB |
Output is correct |
35 |
Correct |
70 ms |
344 KB |
Output is correct |
36 |
Correct |
68 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
432 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
600 KB |
Output is correct |
8 |
Correct |
70 ms |
348 KB |
Output is correct |
9 |
Correct |
70 ms |
408 KB |
Output is correct |
10 |
Correct |
73 ms |
348 KB |
Output is correct |
11 |
Correct |
70 ms |
348 KB |
Output is correct |
12 |
Correct |
73 ms |
344 KB |
Output is correct |
13 |
Correct |
67 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 |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
8 ms |
436 KB |
Output is correct |
21 |
Correct |
65 ms |
348 KB |
Output is correct |
22 |
Correct |
65 ms |
344 KB |
Output is correct |
23 |
Correct |
64 ms |
344 KB |
Output is correct |
24 |
Correct |
75 ms |
344 KB |
Output is correct |
25 |
Correct |
69 ms |
348 KB |
Output is correct |
26 |
Correct |
64 ms |
348 KB |
Output is correct |
27 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
432 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
8 |
Correct |
74 ms |
348 KB |
Output is correct |
9 |
Correct |
71 ms |
348 KB |
Output is correct |
10 |
Correct |
70 ms |
416 KB |
Output is correct |
11 |
Correct |
70 ms |
412 KB |
Output is correct |
12 |
Correct |
72 ms |
348 KB |
Output is correct |
13 |
Correct |
68 ms |
344 KB |
Output is correct |
14 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 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 |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
428 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
8 |
Correct |
70 ms |
412 KB |
Output is correct |
9 |
Correct |
70 ms |
348 KB |
Output is correct |
10 |
Correct |
70 ms |
348 KB |
Output is correct |
11 |
Correct |
70 ms |
348 KB |
Output is correct |
12 |
Correct |
70 ms |
348 KB |
Output is correct |
13 |
Correct |
68 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 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 |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
9 ms |
432 KB |
Output is correct |
21 |
Correct |
66 ms |
348 KB |
Output is correct |
22 |
Correct |
65 ms |
408 KB |
Output is correct |
23 |
Correct |
71 ms |
344 KB |
Output is correct |
24 |
Correct |
72 ms |
348 KB |
Output is correct |
25 |
Correct |
66 ms |
348 KB |
Output is correct |
26 |
Correct |
64 ms |
344 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 |
348 KB |
Output is correct |
30 |
Correct |
34 ms |
348 KB |
Output is correct |
31 |
Correct |
67 ms |
348 KB |
Output is correct |
32 |
Correct |
70 ms |
344 KB |
Output is correct |
33 |
Correct |
69 ms |
412 KB |
Output is correct |
34 |
Correct |
68 ms |
408 KB |
Output is correct |
35 |
Correct |
70 ms |
344 KB |
Output is correct |
36 |
Correct |
68 ms |
344 KB |
Output is correct |
37 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
348 KB |
Output is correct |
8 |
Correct |
70 ms |
348 KB |
Output is correct |
9 |
Correct |
70 ms |
344 KB |
Output is correct |
10 |
Correct |
70 ms |
344 KB |
Output is correct |
11 |
Correct |
71 ms |
348 KB |
Output is correct |
12 |
Correct |
73 ms |
344 KB |
Output is correct |
13 |
Correct |
68 ms |
348 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 |
348 KB |
Output is correct |
17 |
Correct |
34 ms |
440 KB |
Output is correct |
18 |
Correct |
66 ms |
344 KB |
Output is correct |
19 |
Correct |
70 ms |
348 KB |
Output is correct |
20 |
Correct |
65 ms |
344 KB |
Output is correct |
21 |
Correct |
67 ms |
348 KB |
Output is correct |
22 |
Correct |
70 ms |
348 KB |
Output is correct |
23 |
Correct |
68 ms |
348 KB |
Output is correct |
24 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |