#include<bits/stdc++.h>
using namespace std;
const int nax = 2001;
int n, a, b;
long long ans;
int curBit;
int dp[nax][nax];
int tree[nax];
bool good(long long S) {
if(S>>curBit&1) return false;
for(int j=curBit+1; j<60; ++j) {
if((S>>j&1) && (~ans>>j&1)) return false;
}
return true;
}
int solve(int i, int j) {
if(i>n) return j>=a && j<=b;
int &ret = dp[i][j];
if(ret!=-1) return ret;
ret = 0;
long long S = 0;
for(int k=i; k<=n; ++k) {
S += tree[k];
if(good(S)) ret |= solve(k+1, j+1);
if(ret) break;
}
return ret;
}
void PlayGround() {
cin>>n>>a>>b;
for(int i=1; i<=n; ++i) {
cin>>tree[i];
}
for(int i=59; i>=0; --i) {
curBit = i;
memset(dp, -1, sizeof dp);
if(!solve(1, 0)) ans |= 1LL<<i;
}
cout<<ans<<'\n';
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
15972 KB |
Output is correct |
2 |
Correct |
98 ms |
15976 KB |
Output is correct |
3 |
Correct |
98 ms |
15976 KB |
Output is correct |
4 |
Correct |
99 ms |
15972 KB |
Output is correct |
5 |
Correct |
109 ms |
15956 KB |
Output is correct |
6 |
Correct |
123 ms |
15956 KB |
Output is correct |
7 |
Correct |
101 ms |
15988 KB |
Output is correct |
8 |
Correct |
101 ms |
15972 KB |
Output is correct |
9 |
Correct |
101 ms |
15968 KB |
Output is correct |
10 |
Correct |
100 ms |
15972 KB |
Output is correct |
11 |
Correct |
114 ms |
15968 KB |
Output is correct |
12 |
Correct |
106 ms |
15988 KB |
Output is correct |
13 |
Correct |
99 ms |
15980 KB |
Output is correct |
14 |
Correct |
99 ms |
15956 KB |
Output is correct |
15 |
Correct |
100 ms |
15968 KB |
Output is correct |
16 |
Correct |
107 ms |
15984 KB |
Output is correct |
17 |
Correct |
110 ms |
15956 KB |
Output is correct |
18 |
Correct |
99 ms |
15956 KB |
Output is correct |
19 |
Correct |
103 ms |
15956 KB |
Output is correct |
20 |
Correct |
102 ms |
15968 KB |
Output is correct |
21 |
Correct |
104 ms |
15976 KB |
Output is correct |
22 |
Correct |
106 ms |
15972 KB |
Output is correct |
23 |
Correct |
102 ms |
15920 KB |
Output is correct |
24 |
Correct |
105 ms |
15976 KB |
Output is correct |
25 |
Correct |
106 ms |
15956 KB |
Output is correct |
26 |
Correct |
121 ms |
15984 KB |
Output is correct |
27 |
Correct |
105 ms |
15968 KB |
Output is correct |
28 |
Correct |
99 ms |
15972 KB |
Output is correct |
29 |
Correct |
102 ms |
15956 KB |
Output is correct |
30 |
Correct |
103 ms |
15968 KB |
Output is correct |
31 |
Correct |
108 ms |
15980 KB |
Output is correct |
32 |
Correct |
114 ms |
15968 KB |
Output is correct |
33 |
Correct |
106 ms |
15972 KB |
Output is correct |
34 |
Correct |
105 ms |
15976 KB |
Output is correct |
35 |
Correct |
103 ms |
15972 KB |
Output is correct |
36 |
Correct |
110 ms |
15972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
15972 KB |
Output is correct |
2 |
Correct |
105 ms |
15972 KB |
Output is correct |
3 |
Correct |
103 ms |
15968 KB |
Output is correct |
4 |
Correct |
110 ms |
15968 KB |
Output is correct |
5 |
Correct |
104 ms |
15956 KB |
Output is correct |
6 |
Correct |
101 ms |
15992 KB |
Output is correct |
7 |
Correct |
101 ms |
15956 KB |
Output is correct |
8 |
Correct |
101 ms |
15956 KB |
Output is correct |
9 |
Correct |
102 ms |
16080 KB |
Output is correct |
10 |
Correct |
101 ms |
15956 KB |
Output is correct |
11 |
Correct |
102 ms |
15976 KB |
Output is correct |
12 |
Correct |
102 ms |
15968 KB |
Output is correct |
13 |
Correct |
114 ms |
15976 KB |
Output is correct |
14 |
Correct |
104 ms |
15956 KB |
Output is correct |
15 |
Correct |
103 ms |
15972 KB |
Output is correct |
16 |
Correct |
98 ms |
15968 KB |
Output is correct |
17 |
Correct |
98 ms |
15956 KB |
Output is correct |
18 |
Correct |
102 ms |
15972 KB |
Output is correct |
19 |
Correct |
108 ms |
15976 KB |
Output is correct |
20 |
Correct |
104 ms |
15976 KB |
Output is correct |
21 |
Correct |
100 ms |
15956 KB |
Output is correct |
22 |
Correct |
112 ms |
15976 KB |
Output is correct |
23 |
Correct |
103 ms |
15976 KB |
Output is correct |
24 |
Correct |
107 ms |
16076 KB |
Output is correct |
25 |
Correct |
100 ms |
15956 KB |
Output is correct |
26 |
Correct |
108 ms |
15972 KB |
Output is correct |
27 |
Correct |
102 ms |
15956 KB |
Output is correct |
28 |
Correct |
105 ms |
15972 KB |
Output is correct |
29 |
Correct |
126 ms |
15956 KB |
Output is correct |
30 |
Correct |
106 ms |
15972 KB |
Output is correct |
31 |
Correct |
111 ms |
15968 KB |
Output is correct |
32 |
Correct |
117 ms |
15984 KB |
Output is correct |
33 |
Correct |
153 ms |
15956 KB |
Output is correct |
34 |
Correct |
120 ms |
15976 KB |
Output is correct |
35 |
Correct |
116 ms |
15976 KB |
Output is correct |
36 |
Correct |
124 ms |
15972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
109 ms |
15972 KB |
Output is correct |
2 |
Correct |
107 ms |
16076 KB |
Output is correct |
3 |
Correct |
104 ms |
15976 KB |
Output is correct |
4 |
Correct |
105 ms |
15972 KB |
Output is correct |
5 |
Correct |
102 ms |
15976 KB |
Output is correct |
6 |
Correct |
103 ms |
15956 KB |
Output is correct |
7 |
Correct |
110 ms |
15976 KB |
Output is correct |
8 |
Correct |
107 ms |
15972 KB |
Output is correct |
9 |
Correct |
104 ms |
15968 KB |
Output is correct |
10 |
Correct |
112 ms |
15980 KB |
Output is correct |
11 |
Correct |
104 ms |
15976 KB |
Output is correct |
12 |
Correct |
106 ms |
15972 KB |
Output is correct |
13 |
Correct |
100 ms |
15972 KB |
Output is correct |
14 |
Correct |
100 ms |
15972 KB |
Output is correct |
15 |
Correct |
110 ms |
15972 KB |
Output is correct |
16 |
Correct |
118 ms |
15956 KB |
Output is correct |
17 |
Correct |
108 ms |
15976 KB |
Output is correct |
18 |
Correct |
112 ms |
15968 KB |
Output is correct |
19 |
Correct |
110 ms |
15968 KB |
Output is correct |
20 |
Correct |
142 ms |
15980 KB |
Output is correct |
21 |
Correct |
119 ms |
15972 KB |
Output is correct |
22 |
Correct |
112 ms |
15972 KB |
Output is correct |
23 |
Correct |
119 ms |
15912 KB |
Output is correct |
24 |
Correct |
119 ms |
15956 KB |
Output is correct |
25 |
Correct |
167 ms |
16076 KB |
Output is correct |
26 |
Correct |
157 ms |
15976 KB |
Output is correct |
27 |
Correct |
118 ms |
15976 KB |
Output is correct |
28 |
Correct |
109 ms |
15972 KB |
Output is correct |
29 |
Correct |
104 ms |
15972 KB |
Output is correct |
30 |
Correct |
409 ms |
15972 KB |
Output is correct |
31 |
Correct |
143 ms |
15968 KB |
Output is correct |
32 |
Correct |
108 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
15972 KB |
Output is correct |
2 |
Correct |
107 ms |
15968 KB |
Output is correct |
3 |
Correct |
102 ms |
15972 KB |
Output is correct |
4 |
Correct |
107 ms |
15972 KB |
Output is correct |
5 |
Correct |
101 ms |
15976 KB |
Output is correct |
6 |
Correct |
105 ms |
15976 KB |
Output is correct |
7 |
Correct |
105 ms |
15956 KB |
Output is correct |
8 |
Correct |
106 ms |
15956 KB |
Output is correct |
9 |
Correct |
107 ms |
15968 KB |
Output is correct |
10 |
Correct |
104 ms |
15980 KB |
Output is correct |
11 |
Correct |
107 ms |
15956 KB |
Output is correct |
12 |
Correct |
102 ms |
15968 KB |
Output is correct |
13 |
Correct |
103 ms |
15976 KB |
Output is correct |
14 |
Correct |
102 ms |
15972 KB |
Output is correct |
15 |
Correct |
109 ms |
15972 KB |
Output is correct |
16 |
Correct |
117 ms |
15956 KB |
Output is correct |
17 |
Correct |
99 ms |
15972 KB |
Output is correct |
18 |
Correct |
105 ms |
15976 KB |
Output is correct |
19 |
Correct |
103 ms |
15956 KB |
Output is correct |
20 |
Correct |
114 ms |
15956 KB |
Output is correct |
21 |
Correct |
103 ms |
15972 KB |
Output is correct |
22 |
Correct |
111 ms |
15968 KB |
Output is correct |
23 |
Correct |
104 ms |
15976 KB |
Output is correct |
24 |
Correct |
111 ms |
15972 KB |
Output is correct |
25 |
Correct |
107 ms |
15976 KB |
Output is correct |
26 |
Correct |
101 ms |
15956 KB |
Output is correct |
27 |
Correct |
117 ms |
15956 KB |
Output is correct |
28 |
Correct |
107 ms |
15972 KB |
Output is correct |
29 |
Correct |
106 ms |
15972 KB |
Output is correct |
30 |
Correct |
113 ms |
15956 KB |
Output is correct |
31 |
Correct |
111 ms |
15968 KB |
Output is correct |
32 |
Correct |
109 ms |
15976 KB |
Output is correct |
33 |
Correct |
103 ms |
15968 KB |
Output is correct |
34 |
Correct |
102 ms |
15968 KB |
Output is correct |
35 |
Correct |
106 ms |
15980 KB |
Output is correct |
36 |
Correct |
102 ms |
15956 KB |
Output is correct |
37 |
Correct |
98 ms |
15956 KB |
Output is correct |
38 |
Correct |
103 ms |
15968 KB |
Output is correct |
39 |
Correct |
115 ms |
15976 KB |
Output is correct |
40 |
Correct |
108 ms |
15968 KB |
Output is correct |
41 |
Correct |
125 ms |
15968 KB |
Output is correct |
42 |
Correct |
110 ms |
15964 KB |
Output is correct |
43 |
Correct |
140 ms |
15972 KB |
Output is correct |
44 |
Correct |
114 ms |
16076 KB |
Output is correct |
45 |
Correct |
120 ms |
15972 KB |
Output is correct |
46 |
Correct |
125 ms |
15968 KB |
Output is correct |
47 |
Correct |
125 ms |
15972 KB |
Output is correct |
48 |
Correct |
152 ms |
15972 KB |
Output is correct |
49 |
Correct |
150 ms |
15956 KB |
Output is correct |
50 |
Correct |
131 ms |
15972 KB |
Output is correct |
51 |
Correct |
106 ms |
15956 KB |
Output is correct |
52 |
Correct |
101 ms |
15956 KB |
Output is correct |
53 |
Correct |
399 ms |
15972 KB |
Output is correct |
54 |
Correct |
146 ms |
15956 KB |
Output is correct |
55 |
Correct |
102 ms |
15976 KB |
Output is correct |
56 |
Correct |
104 ms |
15984 KB |
Output is correct |
57 |
Correct |
132 ms |
15968 KB |
Output is correct |
58 |
Correct |
110 ms |
15956 KB |
Output is correct |
59 |
Correct |
105 ms |
15956 KB |
Output is correct |
60 |
Correct |
102 ms |
15972 KB |
Output is correct |
61 |
Correct |
186 ms |
15980 KB |
Output is correct |
62 |
Correct |
109 ms |
15956 KB |
Output is correct |
63 |
Correct |
113 ms |
15972 KB |
Output is correct |
64 |
Correct |
105 ms |
15972 KB |
Output is correct |
65 |
Correct |
107 ms |
15884 KB |
Output is correct |
66 |
Correct |
120 ms |
15968 KB |
Output is correct |
67 |
Correct |
126 ms |
15968 KB |
Output is correct |
68 |
Correct |
110 ms |
15956 KB |
Output is correct |
69 |
Correct |
107 ms |
15972 KB |
Output is correct |
70 |
Correct |
111 ms |
15976 KB |
Output is correct |
71 |
Correct |
189 ms |
16084 KB |
Output is correct |
72 |
Correct |
112 ms |
15972 KB |
Output is correct |
73 |
Correct |
114 ms |
15972 KB |
Output is correct |
74 |
Correct |
114 ms |
15956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
15956 KB |
Output is correct |
2 |
Correct |
100 ms |
15956 KB |
Output is correct |
3 |
Correct |
99 ms |
15972 KB |
Output is correct |
4 |
Correct |
100 ms |
15956 KB |
Output is correct |
5 |
Correct |
105 ms |
15968 KB |
Output is correct |
6 |
Correct |
101 ms |
15968 KB |
Output is correct |
7 |
Correct |
101 ms |
15968 KB |
Output is correct |
8 |
Correct |
105 ms |
15976 KB |
Output is correct |
9 |
Correct |
105 ms |
15956 KB |
Output is correct |
10 |
Correct |
113 ms |
15972 KB |
Output is correct |
11 |
Correct |
105 ms |
15968 KB |
Output is correct |
12 |
Correct |
106 ms |
15972 KB |
Output is correct |
13 |
Correct |
100 ms |
15972 KB |
Output is correct |
14 |
Correct |
105 ms |
15968 KB |
Output is correct |
15 |
Correct |
100 ms |
15956 KB |
Output is correct |
16 |
Correct |
114 ms |
15968 KB |
Output is correct |
17 |
Correct |
103 ms |
15956 KB |
Output is correct |
18 |
Correct |
101 ms |
15968 KB |
Output is correct |
19 |
Correct |
102 ms |
15980 KB |
Output is correct |
20 |
Correct |
99 ms |
15968 KB |
Output is correct |
21 |
Correct |
110 ms |
15984 KB |
Output is correct |
22 |
Correct |
106 ms |
15984 KB |
Output is correct |
23 |
Correct |
108 ms |
15968 KB |
Output is correct |
24 |
Correct |
110 ms |
15972 KB |
Output is correct |
25 |
Correct |
102 ms |
16000 KB |
Output is correct |
26 |
Correct |
116 ms |
15956 KB |
Output is correct |
27 |
Correct |
107 ms |
15968 KB |
Output is correct |
28 |
Correct |
115 ms |
15968 KB |
Output is correct |
29 |
Correct |
112 ms |
15976 KB |
Output is correct |
30 |
Correct |
155 ms |
15956 KB |
Output is correct |
31 |
Correct |
112 ms |
15956 KB |
Output is correct |
32 |
Correct |
113 ms |
15956 KB |
Output is correct |
33 |
Correct |
134 ms |
15972 KB |
Output is correct |
34 |
Correct |
110 ms |
15956 KB |
Output is correct |
35 |
Correct |
158 ms |
15976 KB |
Output is correct |
36 |
Correct |
156 ms |
15976 KB |
Output is correct |
37 |
Correct |
117 ms |
15956 KB |
Output is correct |
38 |
Correct |
101 ms |
15972 KB |
Output is correct |
39 |
Correct |
106 ms |
15956 KB |
Output is correct |
40 |
Correct |
373 ms |
15972 KB |
Output is correct |
41 |
Correct |
148 ms |
15972 KB |
Output is correct |
42 |
Correct |
106 ms |
15972 KB |
Output is correct |
43 |
Correct |
104 ms |
15972 KB |
Output is correct |
44 |
Correct |
128 ms |
15956 KB |
Output is correct |
45 |
Correct |
105 ms |
15972 KB |
Output is correct |
46 |
Correct |
101 ms |
16084 KB |
Output is correct |
47 |
Correct |
101 ms |
15972 KB |
Output is correct |
48 |
Correct |
181 ms |
15976 KB |
Output is correct |
49 |
Correct |
105 ms |
15956 KB |
Output is correct |
50 |
Correct |
123 ms |
15972 KB |
Output is correct |
51 |
Correct |
161 ms |
15988 KB |
Output is correct |
52 |
Execution timed out |
1087 ms |
15956 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |