#include <iostream>
using namespace std;
typedef long long int ll;
ll INF=1e18;
ll P=60;
int N,A,B;
ll Y[2005];
ll V[2005];
ll ans,res;
int main(){
cin>>N>>A>>B;
for(int i=0;i<N;i++)
cin>>Y[i];
ans=(1LL<<P)-1;
for(int c=P-1;c>=0;c--){
ans=ans^(1LL<<c);
fill(V,V+N,INF);
for(int i=N-1;i>=0;i--){
res=0;
for(int j=i;j<N;j++){
res+=Y[j];
if((res|ans)==ans)
V[i]=min(V[i],V[j+1]+1);
}
}
if(V[0]==INF or V[0]>B)
ans=ans^(1LL<<c);
//for(int i=0;i<N+1;i++)cout<<(V[i]==INF?-1:V[i])<<" ";cout<<endl;
}
cout<<ans;
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
360 KB |
Output is correct |
4 |
Correct |
3 ms |
420 KB |
Output is correct |
5 |
Correct |
3 ms |
424 KB |
Output is correct |
6 |
Correct |
4 ms |
520 KB |
Output is correct |
7 |
Correct |
2 ms |
572 KB |
Output is correct |
8 |
Correct |
3 ms |
684 KB |
Output is correct |
9 |
Correct |
3 ms |
684 KB |
Output is correct |
10 |
Correct |
3 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
696 KB |
Output is correct |
12 |
Correct |
2 ms |
704 KB |
Output is correct |
13 |
Correct |
3 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
768 KB |
Output is correct |
2 |
Correct |
4 ms |
768 KB |
Output is correct |
3 |
Correct |
2 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
2 ms |
796 KB |
Output is correct |
7 |
Correct |
3 ms |
808 KB |
Output is correct |
8 |
Correct |
3 ms |
808 KB |
Output is correct |
9 |
Correct |
2 ms |
808 KB |
Output is correct |
10 |
Correct |
2 ms |
828 KB |
Output is correct |
11 |
Correct |
2 ms |
828 KB |
Output is correct |
12 |
Correct |
3 ms |
828 KB |
Output is correct |
13 |
Correct |
2 ms |
828 KB |
Output is correct |
14 |
Correct |
2 ms |
828 KB |
Output is correct |
15 |
Incorrect |
2 ms |
828 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
828 KB |
Output is correct |
2 |
Correct |
3 ms |
828 KB |
Output is correct |
3 |
Correct |
3 ms |
828 KB |
Output is correct |
4 |
Correct |
3 ms |
828 KB |
Output is correct |
5 |
Correct |
3 ms |
828 KB |
Output is correct |
6 |
Correct |
2 ms |
828 KB |
Output is correct |
7 |
Correct |
3 ms |
828 KB |
Output is correct |
8 |
Correct |
3 ms |
828 KB |
Output is correct |
9 |
Correct |
3 ms |
828 KB |
Output is correct |
10 |
Correct |
3 ms |
828 KB |
Output is correct |
11 |
Correct |
2 ms |
828 KB |
Output is correct |
12 |
Correct |
3 ms |
828 KB |
Output is correct |
13 |
Correct |
2 ms |
828 KB |
Output is correct |
14 |
Correct |
3 ms |
828 KB |
Output is correct |
15 |
Correct |
2 ms |
828 KB |
Output is correct |
16 |
Correct |
3 ms |
828 KB |
Output is correct |
17 |
Correct |
2 ms |
828 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
3 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
828 KB |
Output is correct |
21 |
Correct |
3 ms |
828 KB |
Output is correct |
22 |
Correct |
4 ms |
828 KB |
Output is correct |
23 |
Correct |
2 ms |
828 KB |
Output is correct |
24 |
Correct |
3 ms |
828 KB |
Output is correct |
25 |
Correct |
3 ms |
828 KB |
Output is correct |
26 |
Correct |
3 ms |
828 KB |
Output is correct |
27 |
Correct |
2 ms |
828 KB |
Output is correct |
28 |
Correct |
4 ms |
828 KB |
Output is correct |
29 |
Correct |
3 ms |
828 KB |
Output is correct |
30 |
Correct |
3 ms |
828 KB |
Output is correct |
31 |
Correct |
4 ms |
828 KB |
Output is correct |
32 |
Correct |
3 ms |
840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
840 KB |
Output is correct |
2 |
Correct |
2 ms |
840 KB |
Output is correct |
3 |
Correct |
2 ms |
840 KB |
Output is correct |
4 |
Correct |
2 ms |
840 KB |
Output is correct |
5 |
Correct |
3 ms |
840 KB |
Output is correct |
6 |
Correct |
3 ms |
840 KB |
Output is correct |
7 |
Correct |
3 ms |
840 KB |
Output is correct |
8 |
Correct |
2 ms |
840 KB |
Output is correct |
9 |
Correct |
3 ms |
840 KB |
Output is correct |
10 |
Correct |
2 ms |
840 KB |
Output is correct |
11 |
Correct |
2 ms |
840 KB |
Output is correct |
12 |
Correct |
2 ms |
840 KB |
Output is correct |
13 |
Correct |
3 ms |
840 KB |
Output is correct |
14 |
Correct |
3 ms |
844 KB |
Output is correct |
15 |
Incorrect |
3 ms |
844 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
844 KB |
Output is correct |
2 |
Correct |
3 ms |
844 KB |
Output is correct |
3 |
Correct |
3 ms |
844 KB |
Output is correct |
4 |
Correct |
2 ms |
844 KB |
Output is correct |
5 |
Correct |
2 ms |
844 KB |
Output is correct |
6 |
Correct |
2 ms |
844 KB |
Output is correct |
7 |
Correct |
3 ms |
844 KB |
Output is correct |
8 |
Correct |
3 ms |
844 KB |
Output is correct |
9 |
Correct |
2 ms |
844 KB |
Output is correct |
10 |
Correct |
3 ms |
844 KB |
Output is correct |
11 |
Correct |
3 ms |
844 KB |
Output is correct |
12 |
Correct |
3 ms |
844 KB |
Output is correct |
13 |
Correct |
3 ms |
844 KB |
Output is correct |
14 |
Correct |
2 ms |
844 KB |
Output is correct |
15 |
Correct |
2 ms |
844 KB |
Output is correct |
16 |
Correct |
2 ms |
844 KB |
Output is correct |
17 |
Correct |
2 ms |
844 KB |
Output is correct |
18 |
Correct |
3 ms |
844 KB |
Output is correct |
19 |
Correct |
2 ms |
856 KB |
Output is correct |
20 |
Correct |
2 ms |
856 KB |
Output is correct |
21 |
Correct |
3 ms |
856 KB |
Output is correct |
22 |
Correct |
3 ms |
868 KB |
Output is correct |
23 |
Correct |
2 ms |
868 KB |
Output is correct |
24 |
Correct |
2 ms |
868 KB |
Output is correct |
25 |
Correct |
3 ms |
868 KB |
Output is correct |
26 |
Correct |
2 ms |
868 KB |
Output is correct |
27 |
Correct |
3 ms |
868 KB |
Output is correct |
28 |
Correct |
3 ms |
868 KB |
Output is correct |
29 |
Correct |
3 ms |
868 KB |
Output is correct |
30 |
Correct |
2 ms |
868 KB |
Output is correct |
31 |
Correct |
4 ms |
908 KB |
Output is correct |
32 |
Correct |
3 ms |
908 KB |
Output is correct |
33 |
Correct |
3 ms |
908 KB |
Output is correct |
34 |
Correct |
2 ms |
916 KB |
Output is correct |
35 |
Correct |
2 ms |
916 KB |
Output is correct |
36 |
Correct |
3 ms |
916 KB |
Output is correct |
37 |
Correct |
4 ms |
928 KB |
Output is correct |
38 |
Correct |
3 ms |
928 KB |
Output is correct |
39 |
Correct |
3 ms |
928 KB |
Output is correct |
40 |
Correct |
4 ms |
940 KB |
Output is correct |
41 |
Correct |
3 ms |
944 KB |
Output is correct |
42 |
Correct |
4 ms |
944 KB |
Output is correct |
43 |
Correct |
3 ms |
952 KB |
Output is correct |
44 |
Correct |
4 ms |
960 KB |
Output is correct |
45 |
Correct |
4 ms |
960 KB |
Output is correct |
46 |
Correct |
3 ms |
964 KB |
Output is correct |
47 |
Correct |
4 ms |
968 KB |
Output is correct |
48 |
Correct |
3 ms |
1220 KB |
Output is correct |
49 |
Correct |
4 ms |
1220 KB |
Output is correct |
50 |
Correct |
4 ms |
1220 KB |
Output is correct |
51 |
Correct |
5 ms |
1220 KB |
Output is correct |
52 |
Correct |
26 ms |
1220 KB |
Output is correct |
53 |
Correct |
45 ms |
1220 KB |
Output is correct |
54 |
Correct |
65 ms |
1220 KB |
Output is correct |
55 |
Correct |
77 ms |
1220 KB |
Output is correct |
56 |
Correct |
247 ms |
1220 KB |
Output is correct |
57 |
Correct |
247 ms |
1220 KB |
Output is correct |
58 |
Correct |
238 ms |
1220 KB |
Output is correct |
59 |
Correct |
240 ms |
1268 KB |
Output is correct |
60 |
Correct |
236 ms |
1268 KB |
Output is correct |
61 |
Correct |
3 ms |
1268 KB |
Output is correct |
62 |
Correct |
34 ms |
1268 KB |
Output is correct |
63 |
Correct |
61 ms |
1268 KB |
Output is correct |
64 |
Correct |
59 ms |
1308 KB |
Output is correct |
65 |
Correct |
107 ms |
1308 KB |
Output is correct |
66 |
Correct |
165 ms |
1308 KB |
Output is correct |
67 |
Correct |
216 ms |
1368 KB |
Output is correct |
68 |
Correct |
225 ms |
1388 KB |
Output is correct |
69 |
Correct |
211 ms |
1448 KB |
Output is correct |