# include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 2;
int n, a[N], dp[N][N], d[N], used[N], l, r;
long long pref[N], ans;
vector <int> g[N];
bool ok(long long x, int ind){
for(int i = ind; i <= 40; i ++){
if((x >> i) % 2 && (ans >> i) % 2 == 0)
return 0;
}
return 1;
}
bool check(int ind){
if(l > 1){
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for(int i = 1; i <= r; i ++){
for(int j = 1; j <= n; j ++){
for(int k = 0; k < j; k ++){
if(ok(pref[j] - pref[k], ind)){
dp[i][j] |= dp[i - 1][k];
}
}
}
}
int ret = 0;
for(int i = l; i <= r; i ++){
ret |= dp[i][n];
}
return ret;
} else {
memset(d, 0x3f3f3f3f, sizeof(d));
memset(used, 0, sizeof(used));
for(int i = 0; i < n; i ++){
g[i].clear();
for(int j = i + 1; j <= n; j ++){
if(ok(pref[j] - pref[i], ind))
g[i].push_back(j);
}
}
d[0] = 0;
used[0] = 1;
queue <int> q;
q.push(0);
while(!q.empty()){
int v = q.front();
q.pop();
for(int to : g[v]){
if(!used[to]){
d[to] = d[v] + 1;
used[to] = 1;
q.push(to);
}
}
}
return d[n] <= r;
}
}
int main(){
cin >> n >> l >> r;
for(int i = 1; i <= n; i ++){
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
for(int i = 40; i >= 0; i --){
if(!check(i))
ans += (1LL << i);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
356 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
116 ms |
16228 KB |
Output is correct |
15 |
Correct |
112 ms |
16100 KB |
Output is correct |
16 |
Correct |
143 ms |
16120 KB |
Output is correct |
17 |
Correct |
150 ms |
16000 KB |
Output is correct |
18 |
Correct |
159 ms |
16000 KB |
Output is correct |
19 |
Correct |
106 ms |
16104 KB |
Output is correct |
20 |
Correct |
139 ms |
16000 KB |
Output is correct |
21 |
Correct |
146 ms |
16000 KB |
Output is correct |
22 |
Correct |
119 ms |
16248 KB |
Output is correct |
23 |
Correct |
86 ms |
16000 KB |
Output is correct |
24 |
Correct |
101 ms |
16128 KB |
Output is correct |
25 |
Correct |
116 ms |
16120 KB |
Output is correct |
26 |
Correct |
132 ms |
16128 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
2 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
4 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 |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
130 ms |
16096 KB |
Output is correct |
15 |
Correct |
128 ms |
15992 KB |
Output is correct |
16 |
Correct |
138 ms |
16128 KB |
Output is correct |
17 |
Correct |
128 ms |
16000 KB |
Output is correct |
18 |
Correct |
123 ms |
16100 KB |
Output is correct |
19 |
Correct |
139 ms |
16220 KB |
Output is correct |
20 |
Correct |
140 ms |
16128 KB |
Output is correct |
21 |
Correct |
137 ms |
16128 KB |
Output is correct |
22 |
Correct |
119 ms |
16248 KB |
Output is correct |
23 |
Correct |
141 ms |
16128 KB |
Output is correct |
24 |
Correct |
135 ms |
16000 KB |
Output is correct |
25 |
Correct |
147 ms |
16000 KB |
Output is correct |
26 |
Correct |
93 ms |
16080 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 |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
384 KB |
Output is correct |
31 |
Correct |
4 ms |
512 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
4 ms |
384 KB |
Output is correct |
34 |
Correct |
4 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
428 KB |
Output is correct |
36 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
512 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
512 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
4 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
384 KB |
Output is correct |
25 |
Correct |
4 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
9 ms |
384 KB |
Output is correct |
28 |
Correct |
7 ms |
512 KB |
Output is correct |
29 |
Correct |
7 ms |
512 KB |
Output is correct |
30 |
Correct |
8 ms |
512 KB |
Output is correct |
31 |
Correct |
7 ms |
384 KB |
Output is correct |
32 |
Correct |
7 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
69 ms |
16128 KB |
Output is correct |
15 |
Correct |
130 ms |
16132 KB |
Output is correct |
16 |
Correct |
111 ms |
16128 KB |
Output is correct |
17 |
Correct |
111 ms |
16096 KB |
Output is correct |
18 |
Correct |
198 ms |
16100 KB |
Output is correct |
19 |
Correct |
169 ms |
16120 KB |
Output is correct |
20 |
Correct |
103 ms |
16100 KB |
Output is correct |
21 |
Correct |
136 ms |
16100 KB |
Output is correct |
22 |
Correct |
157 ms |
16128 KB |
Output is correct |
23 |
Correct |
153 ms |
16096 KB |
Output is correct |
24 |
Correct |
141 ms |
16128 KB |
Output is correct |
25 |
Correct |
147 ms |
16136 KB |
Output is correct |
26 |
Correct |
159 ms |
16132 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
3 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
4 ms |
384 KB |
Output is correct |
36 |
Correct |
3 ms |
384 KB |
Output is correct |
37 |
Correct |
2 ms |
384 KB |
Output is correct |
38 |
Correct |
3 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
4 ms |
384 KB |
Output is correct |
41 |
Correct |
4 ms |
384 KB |
Output is correct |
42 |
Correct |
3 ms |
384 KB |
Output is correct |
43 |
Correct |
5 ms |
412 KB |
Output is correct |
44 |
Correct |
5 ms |
384 KB |
Output is correct |
45 |
Correct |
4 ms |
384 KB |
Output is correct |
46 |
Correct |
4 ms |
512 KB |
Output is correct |
47 |
Correct |
4 ms |
384 KB |
Output is correct |
48 |
Correct |
5 ms |
384 KB |
Output is correct |
49 |
Correct |
5 ms |
384 KB |
Output is correct |
50 |
Correct |
7 ms |
512 KB |
Output is correct |
51 |
Correct |
7 ms |
384 KB |
Output is correct |
52 |
Correct |
9 ms |
384 KB |
Output is correct |
53 |
Correct |
7 ms |
384 KB |
Output is correct |
54 |
Correct |
6 ms |
512 KB |
Output is correct |
55 |
Correct |
9 ms |
476 KB |
Output is correct |
56 |
Correct |
4 ms |
384 KB |
Output is correct |
57 |
Correct |
7 ms |
384 KB |
Output is correct |
58 |
Correct |
9 ms |
384 KB |
Output is correct |
59 |
Correct |
9 ms |
384 KB |
Output is correct |
60 |
Correct |
4 ms |
384 KB |
Output is correct |
61 |
Correct |
4 ms |
384 KB |
Output is correct |
62 |
Correct |
9 ms |
384 KB |
Output is correct |
63 |
Correct |
8 ms |
384 KB |
Output is correct |
64 |
Correct |
489 ms |
16132 KB |
Output is correct |
65 |
Correct |
171 ms |
16000 KB |
Output is correct |
66 |
Correct |
170 ms |
16248 KB |
Output is correct |
67 |
Correct |
237 ms |
16248 KB |
Output is correct |
68 |
Correct |
461 ms |
16248 KB |
Output is correct |
69 |
Correct |
860 ms |
16000 KB |
Output is correct |
70 |
Correct |
305 ms |
16104 KB |
Output is correct |
71 |
Correct |
139 ms |
16000 KB |
Output is correct |
72 |
Correct |
643 ms |
16248 KB |
Output is correct |
73 |
Correct |
547 ms |
16120 KB |
Output is correct |
74 |
Correct |
440 ms |
16104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
1 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 |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
4 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
4 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
384 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
33 |
Correct |
4 ms |
384 KB |
Output is correct |
34 |
Correct |
5 ms |
384 KB |
Output is correct |
35 |
Correct |
5 ms |
384 KB |
Output is correct |
36 |
Correct |
5 ms |
384 KB |
Output is correct |
37 |
Correct |
9 ms |
384 KB |
Output is correct |
38 |
Correct |
7 ms |
384 KB |
Output is correct |
39 |
Correct |
7 ms |
512 KB |
Output is correct |
40 |
Correct |
7 ms |
512 KB |
Output is correct |
41 |
Correct |
6 ms |
384 KB |
Output is correct |
42 |
Correct |
7 ms |
512 KB |
Output is correct |
43 |
Correct |
1 ms |
384 KB |
Output is correct |
44 |
Correct |
7 ms |
384 KB |
Output is correct |
45 |
Correct |
11 ms |
384 KB |
Output is correct |
46 |
Correct |
12 ms |
384 KB |
Output is correct |
47 |
Correct |
6 ms |
460 KB |
Output is correct |
48 |
Correct |
4 ms |
384 KB |
Output is correct |
49 |
Correct |
8 ms |
384 KB |
Output is correct |
50 |
Correct |
7 ms |
512 KB |
Output is correct |
51 |
Correct |
9 ms |
384 KB |
Output is correct |
52 |
Correct |
242 ms |
1408 KB |
Output is correct |
53 |
Correct |
463 ms |
2116 KB |
Output is correct |
54 |
Correct |
596 ms |
3164 KB |
Output is correct |
55 |
Correct |
747 ms |
3072 KB |
Output is correct |
56 |
Execution timed out |
1067 ms |
11000 KB |
Time limit exceeded |
57 |
Halted |
0 ms |
0 KB |
- |