// Muallif: Azimjon Mehmonali o'g'li
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = (1ll << 35) - 1;
const int N = 2111;
const int K = 2111;
int n, k, a, b;
int y[N], p[N], dp[K][N], pp[K][N];
bool check(int mask, int cand) { return !(~mask & cand); }
bool can(int mask) {
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= n; i++)
dp[0][i] = check(mask, p[i]);
for (int k = 1; k <= n; k++) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j < i; j++) {
dp[k][i] |= dp[k - 1][j] && check(mask, p[i] - p[j]);
}
}
}
bool fl = 0;
for (int i = a; i <= b; i++) {
fl |= dp[i - 1][n];
}
return fl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> a >> b;
for (int i = 1; i <= n; i++) {
cin >> y[i];
p[i] = p[i - 1] + y[i];
}
int nt = (1ll << 51) - 1;
for (int i = 50; i >= 0; i--) {
if (can(nt - (1ll << i))) {
nt -= (1ll << i);
}
}
cout << nt << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
251 ms |
35188 KB |
Output is correct |
2 |
Correct |
254 ms |
35148 KB |
Output is correct |
3 |
Correct |
243 ms |
35148 KB |
Output is correct |
4 |
Correct |
248 ms |
35244 KB |
Output is correct |
5 |
Correct |
246 ms |
35148 KB |
Output is correct |
6 |
Correct |
243 ms |
35200 KB |
Output is correct |
7 |
Correct |
254 ms |
35136 KB |
Output is correct |
8 |
Correct |
252 ms |
35148 KB |
Output is correct |
9 |
Correct |
246 ms |
35148 KB |
Output is correct |
10 |
Correct |
242 ms |
35176 KB |
Output is correct |
11 |
Correct |
242 ms |
35188 KB |
Output is correct |
12 |
Correct |
243 ms |
35188 KB |
Output is correct |
13 |
Correct |
244 ms |
35152 KB |
Output is correct |
14 |
Correct |
242 ms |
35268 KB |
Output is correct |
15 |
Correct |
249 ms |
35268 KB |
Output is correct |
16 |
Correct |
244 ms |
35144 KB |
Output is correct |
17 |
Correct |
249 ms |
35268 KB |
Output is correct |
18 |
Correct |
251 ms |
35200 KB |
Output is correct |
19 |
Correct |
245 ms |
35148 KB |
Output is correct |
20 |
Correct |
244 ms |
35320 KB |
Output is correct |
21 |
Correct |
242 ms |
35132 KB |
Output is correct |
22 |
Correct |
243 ms |
35148 KB |
Output is correct |
23 |
Correct |
257 ms |
35148 KB |
Output is correct |
24 |
Correct |
250 ms |
35196 KB |
Output is correct |
25 |
Correct |
247 ms |
35128 KB |
Output is correct |
26 |
Correct |
254 ms |
35196 KB |
Output is correct |
27 |
Correct |
245 ms |
35196 KB |
Output is correct |
28 |
Correct |
257 ms |
35188 KB |
Output is correct |
29 |
Correct |
248 ms |
35188 KB |
Output is correct |
30 |
Correct |
251 ms |
35188 KB |
Output is correct |
31 |
Correct |
256 ms |
35208 KB |
Output is correct |
32 |
Correct |
255 ms |
35196 KB |
Output is correct |
33 |
Correct |
247 ms |
35192 KB |
Output is correct |
34 |
Correct |
248 ms |
35140 KB |
Output is correct |
35 |
Correct |
248 ms |
35148 KB |
Output is correct |
36 |
Correct |
253 ms |
35192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
244 ms |
35268 KB |
Output is correct |
2 |
Correct |
245 ms |
35200 KB |
Output is correct |
3 |
Correct |
248 ms |
35188 KB |
Output is correct |
4 |
Correct |
249 ms |
35120 KB |
Output is correct |
5 |
Correct |
244 ms |
35268 KB |
Output is correct |
6 |
Correct |
245 ms |
35132 KB |
Output is correct |
7 |
Correct |
245 ms |
35148 KB |
Output is correct |
8 |
Correct |
245 ms |
35184 KB |
Output is correct |
9 |
Correct |
247 ms |
35136 KB |
Output is correct |
10 |
Correct |
244 ms |
35188 KB |
Output is correct |
11 |
Correct |
249 ms |
35192 KB |
Output is correct |
12 |
Correct |
244 ms |
35188 KB |
Output is correct |
13 |
Correct |
254 ms |
35148 KB |
Output is correct |
14 |
Correct |
246 ms |
35196 KB |
Output is correct |
15 |
Correct |
247 ms |
35184 KB |
Output is correct |
16 |
Correct |
254 ms |
35192 KB |
Output is correct |
17 |
Correct |
244 ms |
35272 KB |
Output is correct |
18 |
Correct |
242 ms |
35148 KB |
Output is correct |
19 |
Correct |
249 ms |
35268 KB |
Output is correct |
20 |
Correct |
242 ms |
35148 KB |
Output is correct |
21 |
Correct |
246 ms |
35196 KB |
Output is correct |
22 |
Correct |
242 ms |
35188 KB |
Output is correct |
23 |
Correct |
249 ms |
35148 KB |
Output is correct |
24 |
Correct |
247 ms |
35192 KB |
Output is correct |
25 |
Correct |
245 ms |
35148 KB |
Output is correct |
26 |
Correct |
240 ms |
35192 KB |
Output is correct |
27 |
Correct |
251 ms |
35148 KB |
Output is correct |
28 |
Correct |
250 ms |
35176 KB |
Output is correct |
29 |
Correct |
248 ms |
35088 KB |
Output is correct |
30 |
Correct |
245 ms |
35148 KB |
Output is correct |
31 |
Correct |
246 ms |
35148 KB |
Output is correct |
32 |
Correct |
249 ms |
35248 KB |
Output is correct |
33 |
Correct |
251 ms |
35320 KB |
Output is correct |
34 |
Correct |
252 ms |
35148 KB |
Output is correct |
35 |
Correct |
252 ms |
35268 KB |
Output is correct |
36 |
Correct |
249 ms |
35200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
245 ms |
35148 KB |
Output is correct |
2 |
Correct |
250 ms |
35200 KB |
Output is correct |
3 |
Correct |
244 ms |
35200 KB |
Output is correct |
4 |
Correct |
244 ms |
35188 KB |
Output is correct |
5 |
Correct |
248 ms |
35200 KB |
Output is correct |
6 |
Correct |
253 ms |
35148 KB |
Output is correct |
7 |
Correct |
247 ms |
35268 KB |
Output is correct |
8 |
Correct |
244 ms |
35224 KB |
Output is correct |
9 |
Correct |
253 ms |
35148 KB |
Output is correct |
10 |
Correct |
253 ms |
35184 KB |
Output is correct |
11 |
Correct |
255 ms |
35148 KB |
Output is correct |
12 |
Correct |
259 ms |
35152 KB |
Output is correct |
13 |
Correct |
252 ms |
35144 KB |
Output is correct |
14 |
Correct |
250 ms |
35192 KB |
Output is correct |
15 |
Correct |
250 ms |
35268 KB |
Output is correct |
16 |
Correct |
253 ms |
35200 KB |
Output is correct |
17 |
Correct |
250 ms |
35148 KB |
Output is correct |
18 |
Correct |
253 ms |
35200 KB |
Output is correct |
19 |
Correct |
249 ms |
35204 KB |
Output is correct |
20 |
Correct |
249 ms |
35196 KB |
Output is correct |
21 |
Correct |
256 ms |
35188 KB |
Output is correct |
22 |
Correct |
251 ms |
35212 KB |
Output is correct |
23 |
Correct |
249 ms |
35148 KB |
Output is correct |
24 |
Correct |
254 ms |
35204 KB |
Output is correct |
25 |
Correct |
254 ms |
35148 KB |
Output is correct |
26 |
Correct |
262 ms |
35228 KB |
Output is correct |
27 |
Correct |
271 ms |
35148 KB |
Output is correct |
28 |
Correct |
281 ms |
35180 KB |
Output is correct |
29 |
Correct |
276 ms |
35196 KB |
Output is correct |
30 |
Correct |
276 ms |
35196 KB |
Output is correct |
31 |
Correct |
274 ms |
35268 KB |
Output is correct |
32 |
Correct |
277 ms |
35200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
35200 KB |
Output is correct |
2 |
Correct |
247 ms |
35188 KB |
Output is correct |
3 |
Correct |
249 ms |
35268 KB |
Output is correct |
4 |
Correct |
248 ms |
35184 KB |
Output is correct |
5 |
Correct |
250 ms |
35188 KB |
Output is correct |
6 |
Correct |
245 ms |
35192 KB |
Output is correct |
7 |
Correct |
250 ms |
35188 KB |
Output is correct |
8 |
Correct |
245 ms |
35188 KB |
Output is correct |
9 |
Correct |
246 ms |
35148 KB |
Output is correct |
10 |
Correct |
246 ms |
35148 KB |
Output is correct |
11 |
Correct |
244 ms |
35148 KB |
Output is correct |
12 |
Correct |
245 ms |
35196 KB |
Output is correct |
13 |
Correct |
251 ms |
35268 KB |
Output is correct |
14 |
Correct |
243 ms |
35148 KB |
Output is correct |
15 |
Correct |
250 ms |
35148 KB |
Output is correct |
16 |
Correct |
247 ms |
35200 KB |
Output is correct |
17 |
Correct |
247 ms |
35192 KB |
Output is correct |
18 |
Correct |
243 ms |
35256 KB |
Output is correct |
19 |
Correct |
253 ms |
35148 KB |
Output is correct |
20 |
Correct |
247 ms |
35204 KB |
Output is correct |
21 |
Correct |
248 ms |
35148 KB |
Output is correct |
22 |
Correct |
249 ms |
35136 KB |
Output is correct |
23 |
Correct |
247 ms |
35196 KB |
Output is correct |
24 |
Correct |
244 ms |
35156 KB |
Output is correct |
25 |
Correct |
252 ms |
35192 KB |
Output is correct |
26 |
Correct |
241 ms |
35084 KB |
Output is correct |
27 |
Correct |
244 ms |
35192 KB |
Output is correct |
28 |
Correct |
247 ms |
35204 KB |
Output is correct |
29 |
Correct |
242 ms |
35140 KB |
Output is correct |
30 |
Correct |
244 ms |
35188 KB |
Output is correct |
31 |
Correct |
247 ms |
35360 KB |
Output is correct |
32 |
Correct |
244 ms |
35192 KB |
Output is correct |
33 |
Correct |
249 ms |
35268 KB |
Output is correct |
34 |
Correct |
250 ms |
35084 KB |
Output is correct |
35 |
Correct |
247 ms |
35268 KB |
Output is correct |
36 |
Correct |
246 ms |
35204 KB |
Output is correct |
37 |
Correct |
245 ms |
35148 KB |
Output is correct |
38 |
Correct |
250 ms |
35188 KB |
Output is correct |
39 |
Correct |
253 ms |
35148 KB |
Output is correct |
40 |
Correct |
251 ms |
35156 KB |
Output is correct |
41 |
Correct |
252 ms |
35192 KB |
Output is correct |
42 |
Correct |
250 ms |
35268 KB |
Output is correct |
43 |
Correct |
252 ms |
35196 KB |
Output is correct |
44 |
Correct |
252 ms |
35192 KB |
Output is correct |
45 |
Correct |
254 ms |
35140 KB |
Output is correct |
46 |
Correct |
249 ms |
35204 KB |
Output is correct |
47 |
Correct |
252 ms |
35268 KB |
Output is correct |
48 |
Correct |
260 ms |
35192 KB |
Output is correct |
49 |
Correct |
262 ms |
35268 KB |
Output is correct |
50 |
Correct |
270 ms |
35268 KB |
Output is correct |
51 |
Correct |
278 ms |
35148 KB |
Output is correct |
52 |
Correct |
282 ms |
35172 KB |
Output is correct |
53 |
Correct |
275 ms |
35192 KB |
Output is correct |
54 |
Correct |
276 ms |
35208 KB |
Output is correct |
55 |
Correct |
277 ms |
35208 KB |
Output is correct |
56 |
Correct |
247 ms |
35204 KB |
Output is correct |
57 |
Correct |
265 ms |
35192 KB |
Output is correct |
58 |
Correct |
272 ms |
35148 KB |
Output is correct |
59 |
Correct |
273 ms |
35148 KB |
Output is correct |
60 |
Correct |
278 ms |
35272 KB |
Output is correct |
61 |
Correct |
273 ms |
35140 KB |
Output is correct |
62 |
Correct |
277 ms |
35148 KB |
Output is correct |
63 |
Correct |
274 ms |
35208 KB |
Output is correct |
64 |
Correct |
266 ms |
35144 KB |
Output is correct |
65 |
Correct |
254 ms |
35208 KB |
Output is correct |
66 |
Correct |
253 ms |
35268 KB |
Output is correct |
67 |
Correct |
261 ms |
35168 KB |
Output is correct |
68 |
Correct |
269 ms |
35168 KB |
Output is correct |
69 |
Correct |
273 ms |
35268 KB |
Output is correct |
70 |
Correct |
280 ms |
35192 KB |
Output is correct |
71 |
Correct |
278 ms |
35208 KB |
Output is correct |
72 |
Correct |
279 ms |
35196 KB |
Output is correct |
73 |
Correct |
280 ms |
35148 KB |
Output is correct |
74 |
Correct |
275 ms |
35112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
247 ms |
35148 KB |
Output is correct |
2 |
Correct |
249 ms |
35192 KB |
Output is correct |
3 |
Correct |
246 ms |
35148 KB |
Output is correct |
4 |
Correct |
242 ms |
35148 KB |
Output is correct |
5 |
Correct |
243 ms |
35148 KB |
Output is correct |
6 |
Correct |
245 ms |
35200 KB |
Output is correct |
7 |
Correct |
245 ms |
35188 KB |
Output is correct |
8 |
Correct |
245 ms |
35272 KB |
Output is correct |
9 |
Correct |
248 ms |
35148 KB |
Output is correct |
10 |
Correct |
251 ms |
35260 KB |
Output is correct |
11 |
Correct |
252 ms |
35196 KB |
Output is correct |
12 |
Correct |
253 ms |
35196 KB |
Output is correct |
13 |
Correct |
249 ms |
35268 KB |
Output is correct |
14 |
Correct |
257 ms |
35188 KB |
Output is correct |
15 |
Correct |
257 ms |
35268 KB |
Output is correct |
16 |
Correct |
261 ms |
35148 KB |
Output is correct |
17 |
Correct |
250 ms |
35148 KB |
Output is correct |
18 |
Correct |
259 ms |
35316 KB |
Output is correct |
19 |
Correct |
258 ms |
35148 KB |
Output is correct |
20 |
Correct |
252 ms |
35316 KB |
Output is correct |
21 |
Correct |
245 ms |
35196 KB |
Output is correct |
22 |
Correct |
247 ms |
35148 KB |
Output is correct |
23 |
Correct |
247 ms |
35148 KB |
Output is correct |
24 |
Correct |
246 ms |
35200 KB |
Output is correct |
25 |
Correct |
250 ms |
35188 KB |
Output is correct |
26 |
Correct |
247 ms |
35120 KB |
Output is correct |
27 |
Correct |
252 ms |
35148 KB |
Output is correct |
28 |
Correct |
250 ms |
35148 KB |
Output is correct |
29 |
Correct |
260 ms |
35148 KB |
Output is correct |
30 |
Correct |
248 ms |
35192 KB |
Output is correct |
31 |
Correct |
250 ms |
35200 KB |
Output is correct |
32 |
Correct |
254 ms |
35280 KB |
Output is correct |
33 |
Correct |
255 ms |
35148 KB |
Output is correct |
34 |
Correct |
251 ms |
35196 KB |
Output is correct |
35 |
Correct |
262 ms |
35268 KB |
Output is correct |
36 |
Correct |
269 ms |
35148 KB |
Output is correct |
37 |
Correct |
279 ms |
35192 KB |
Output is correct |
38 |
Correct |
280 ms |
35116 KB |
Output is correct |
39 |
Correct |
282 ms |
35200 KB |
Output is correct |
40 |
Correct |
291 ms |
35248 KB |
Output is correct |
41 |
Correct |
285 ms |
35148 KB |
Output is correct |
42 |
Correct |
286 ms |
35228 KB |
Output is correct |
43 |
Correct |
263 ms |
35148 KB |
Output is correct |
44 |
Correct |
268 ms |
35196 KB |
Output is correct |
45 |
Correct |
281 ms |
35172 KB |
Output is correct |
46 |
Correct |
285 ms |
35196 KB |
Output is correct |
47 |
Correct |
287 ms |
35212 KB |
Output is correct |
48 |
Correct |
283 ms |
35204 KB |
Output is correct |
49 |
Correct |
288 ms |
35152 KB |
Output is correct |
50 |
Correct |
283 ms |
35212 KB |
Output is correct |
51 |
Correct |
283 ms |
35148 KB |
Output is correct |
52 |
Execution timed out |
1065 ms |
35148 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |