#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int N, A, B;
vector<lint> sum{0};
lint notbit = 0;
lint dp[105][105];
bool minimum(int now, int cnt){
if(now == N){
return (A <= cnt && cnt <= B);
}else if(dp[now][cnt] != -1){
return dp[now][cnt];
}
bool ans = false;
for(int i = now + 1; i <= N; i++){
if(((sum[i] - sum[now]) & notbit) == 0){
ans |= minimum(i, cnt + 1);
}
}
return ans;
}
int main(){
cin >> N >> A >> B;
for(int i = 0; i < N; i++){
lint Y;
cin >> Y;
lint item = sum.back() + Y;
sum.push_back(item);
}
for(int i = 59; i >= 0; i--){
notbit += (1l << i);
memset(dp, -1, sizeof(dp));
if(!minimum(0, 0)){
notbit -= (1l << i);
}
}
cout << (1l << 60) - 1 - notbit << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
12 ms |
384 KB |
Output is correct |
7 |
Correct |
40 ms |
384 KB |
Output is correct |
8 |
Correct |
324 ms |
476 KB |
Output is correct |
9 |
Correct |
310 ms |
504 KB |
Output is correct |
10 |
Correct |
352 ms |
504 KB |
Output is correct |
11 |
Correct |
358 ms |
504 KB |
Output is correct |
12 |
Correct |
340 ms |
504 KB |
Output is correct |
13 |
Correct |
349 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
12 ms |
384 KB |
Output is correct |
20 |
Correct |
40 ms |
408 KB |
Output is correct |
21 |
Correct |
310 ms |
476 KB |
Output is correct |
22 |
Correct |
304 ms |
384 KB |
Output is correct |
23 |
Correct |
307 ms |
384 KB |
Output is correct |
24 |
Correct |
352 ms |
504 KB |
Output is correct |
25 |
Correct |
421 ms |
384 KB |
Output is correct |
26 |
Correct |
336 ms |
548 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
4 ms |
384 KB |
Output is correct |
30 |
Correct |
80 ms |
384 KB |
Output is correct |
31 |
Correct |
161 ms |
440 KB |
Output is correct |
32 |
Correct |
163 ms |
384 KB |
Output is correct |
33 |
Correct |
259 ms |
384 KB |
Output is correct |
34 |
Correct |
247 ms |
504 KB |
Output is correct |
35 |
Correct |
253 ms |
440 KB |
Output is correct |
36 |
Correct |
253 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
12 ms |
384 KB |
Output is correct |
7 |
Correct |
40 ms |
384 KB |
Output is correct |
8 |
Correct |
323 ms |
504 KB |
Output is correct |
9 |
Correct |
360 ms |
504 KB |
Output is correct |
10 |
Correct |
349 ms |
504 KB |
Output is correct |
11 |
Correct |
366 ms |
436 KB |
Output is correct |
12 |
Correct |
316 ms |
384 KB |
Output is correct |
13 |
Correct |
336 ms |
476 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
12 ms |
384 KB |
Output is correct |
20 |
Correct |
40 ms |
384 KB |
Output is correct |
21 |
Correct |
330 ms |
444 KB |
Output is correct |
22 |
Correct |
321 ms |
504 KB |
Output is correct |
23 |
Correct |
305 ms |
384 KB |
Output is correct |
24 |
Correct |
317 ms |
384 KB |
Output is correct |
25 |
Correct |
315 ms |
504 KB |
Output is correct |
26 |
Correct |
315 ms |
384 KB |
Output is correct |
27 |
Correct |
662 ms |
504 KB |
Output is correct |
28 |
Execution timed out |
1081 ms |
384 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
12 ms |
384 KB |
Output is correct |
7 |
Correct |
41 ms |
384 KB |
Output is correct |
8 |
Correct |
309 ms |
384 KB |
Output is correct |
9 |
Correct |
318 ms |
504 KB |
Output is correct |
10 |
Correct |
314 ms |
384 KB |
Output is correct |
11 |
Correct |
321 ms |
504 KB |
Output is correct |
12 |
Correct |
320 ms |
504 KB |
Output is correct |
13 |
Correct |
314 ms |
384 KB |
Output is correct |
14 |
Correct |
625 ms |
472 KB |
Output is correct |
15 |
Execution timed out |
1054 ms |
384 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
41 ms |
384 KB |
Output is correct |
8 |
Correct |
336 ms |
440 KB |
Output is correct |
9 |
Correct |
309 ms |
384 KB |
Output is correct |
10 |
Correct |
340 ms |
384 KB |
Output is correct |
11 |
Correct |
339 ms |
376 KB |
Output is correct |
12 |
Correct |
341 ms |
476 KB |
Output is correct |
13 |
Correct |
332 ms |
504 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
13 ms |
384 KB |
Output is correct |
20 |
Correct |
44 ms |
476 KB |
Output is correct |
21 |
Correct |
317 ms |
384 KB |
Output is correct |
22 |
Correct |
311 ms |
384 KB |
Output is correct |
23 |
Correct |
305 ms |
504 KB |
Output is correct |
24 |
Correct |
310 ms |
504 KB |
Output is correct |
25 |
Correct |
312 ms |
384 KB |
Output is correct |
26 |
Correct |
389 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
4 ms |
404 KB |
Output is correct |
30 |
Correct |
86 ms |
504 KB |
Output is correct |
31 |
Correct |
183 ms |
512 KB |
Output is correct |
32 |
Correct |
166 ms |
384 KB |
Output is correct |
33 |
Correct |
200 ms |
504 KB |
Output is correct |
34 |
Correct |
188 ms |
504 KB |
Output is correct |
35 |
Correct |
246 ms |
504 KB |
Output is correct |
36 |
Correct |
254 ms |
476 KB |
Output is correct |
37 |
Correct |
641 ms |
440 KB |
Output is correct |
38 |
Execution timed out |
1014 ms |
428 KB |
Time limit exceeded |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
13 ms |
384 KB |
Output is correct |
7 |
Correct |
41 ms |
384 KB |
Output is correct |
8 |
Correct |
365 ms |
476 KB |
Output is correct |
9 |
Correct |
331 ms |
420 KB |
Output is correct |
10 |
Correct |
332 ms |
384 KB |
Output is correct |
11 |
Correct |
318 ms |
384 KB |
Output is correct |
12 |
Correct |
344 ms |
384 KB |
Output is correct |
13 |
Correct |
329 ms |
380 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
99 ms |
384 KB |
Output is correct |
18 |
Correct |
254 ms |
384 KB |
Output is correct |
19 |
Correct |
164 ms |
384 KB |
Output is correct |
20 |
Correct |
216 ms |
384 KB |
Output is correct |
21 |
Correct |
195 ms |
504 KB |
Output is correct |
22 |
Correct |
271 ms |
504 KB |
Output is correct |
23 |
Correct |
305 ms |
480 KB |
Output is correct |
24 |
Correct |
801 ms |
384 KB |
Output is correct |
25 |
Execution timed out |
1024 ms |
384 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |