#include <bits/stdc++.h>
#include <random>
#include <ext/rope>
#include <complex>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
const int maxn = 2000;
const int maxa = 1e9;
const int64_t maxs = 41;
int main()
{
int64_t n,A,B;
cin >> n >> A >> B;
int64_t y[n];
for(int i = 0;i < n;++i)
{
cin >> y[i];
}
if(n <= 100)
{
int64_t mask = ((1ll<<42)-1);
for(int64_t b = maxs;b >= 0;--b)
{
mask &= (~(1ll<<b));
int64_t dp[n+1][n+1];
for(int j = 0;j <= n;++j)
{
if(j == 0)
dp[n][j] = 1;
else
dp[n][j] = 0;
}
for(int i = n-1;i >= 0;--i)
{
for(int j = 0;j <= n;++j)
dp[i][j] = 0;
int64_t tsum = 0;
for(int j = i;j < n;++j)
{
tsum += y[j];
// cout << tsum << ' ' << mask << ' ' << (tsum&mask) << "\n";
if((tsum&mask) == tsum)
{
for(int k= 0;k <= n;++k)
{
if(dp[j+1][k] == 1)
dp[i][k+1] = 1;
}
}
}
}
int yes = 0;
for(int i =A;i <= B;++i)
{
if(dp[0][i])
yes = 1;
}
if(!yes)
{
mask |= (1ll<<b);
}
}
cout << mask;
return 0;
}
else
{
int64_t mask = ((1ll<<42)-1);
for(int64_t b = maxs;b >= 0;--b)
{
mask &= (~(1ll<<b));
int64_t dp[n+1];
dp[n] = 0;
for(int i = n-1;i >= 0;--i)
{
dp[i] = n+1;
int64_t tsum = 0;
for(int j = i;j < n;++j)
{
tsum += y[j];
if((tsum&mask) == tsum)
{
dp[i] = min(dp[i],dp[j+1]+1);
}
}
}
if(dp[0] > B)
{
mask |= (1ll<<b);
}
}
cout << mask;
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
304 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
304 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
300 KB |
Output is correct |
21 |
Correct |
1 ms |
300 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
296 KB |
Output is correct |
32 |
Correct |
1 ms |
296 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
296 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
300 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
300 KB |
Output is correct |
24 |
Correct |
1 ms |
300 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
296 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
3 ms |
300 KB |
Output is correct |
30 |
Correct |
2 ms |
212 KB |
Output is correct |
31 |
Correct |
3 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
212 KB |
Output is correct |
33 |
Correct |
3 ms |
296 KB |
Output is correct |
34 |
Correct |
3 ms |
212 KB |
Output is correct |
35 |
Correct |
3 ms |
212 KB |
Output is correct |
36 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
300 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
3 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
300 KB |
Output is correct |
19 |
Correct |
3 ms |
300 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
3 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
296 KB |
Output is correct |
25 |
Correct |
5 ms |
212 KB |
Output is correct |
26 |
Correct |
9 ms |
300 KB |
Output is correct |
27 |
Correct |
12 ms |
364 KB |
Output is correct |
28 |
Correct |
18 ms |
340 KB |
Output is correct |
29 |
Correct |
20 ms |
376 KB |
Output is correct |
30 |
Correct |
17 ms |
376 KB |
Output is correct |
31 |
Correct |
15 ms |
340 KB |
Output is correct |
32 |
Correct |
15 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
296 KB |
Output is correct |
10 |
Correct |
1 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
300 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
300 KB |
Output is correct |
25 |
Correct |
1 ms |
296 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
300 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
1 ms |
296 KB |
Output is correct |
32 |
Correct |
1 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
2 ms |
212 KB |
Output is correct |
40 |
Correct |
2 ms |
212 KB |
Output is correct |
41 |
Correct |
3 ms |
212 KB |
Output is correct |
42 |
Correct |
3 ms |
212 KB |
Output is correct |
43 |
Correct |
4 ms |
212 KB |
Output is correct |
44 |
Correct |
3 ms |
316 KB |
Output is correct |
45 |
Correct |
3 ms |
212 KB |
Output is correct |
46 |
Correct |
3 ms |
212 KB |
Output is correct |
47 |
Correct |
4 ms |
300 KB |
Output is correct |
48 |
Correct |
5 ms |
332 KB |
Output is correct |
49 |
Correct |
8 ms |
304 KB |
Output is correct |
50 |
Correct |
15 ms |
364 KB |
Output is correct |
51 |
Correct |
17 ms |
376 KB |
Output is correct |
52 |
Correct |
15 ms |
340 KB |
Output is correct |
53 |
Correct |
17 ms |
340 KB |
Output is correct |
54 |
Correct |
16 ms |
340 KB |
Output is correct |
55 |
Correct |
16 ms |
368 KB |
Output is correct |
56 |
Correct |
1 ms |
212 KB |
Output is correct |
57 |
Correct |
3 ms |
340 KB |
Output is correct |
58 |
Correct |
4 ms |
340 KB |
Output is correct |
59 |
Correct |
5 ms |
304 KB |
Output is correct |
60 |
Correct |
4 ms |
340 KB |
Output is correct |
61 |
Correct |
6 ms |
340 KB |
Output is correct |
62 |
Correct |
7 ms |
340 KB |
Output is correct |
63 |
Correct |
6 ms |
340 KB |
Output is correct |
64 |
Correct |
13 ms |
340 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Correct |
2 ms |
212 KB |
Output is correct |
67 |
Correct |
3 ms |
340 KB |
Output is correct |
68 |
Correct |
4 ms |
340 KB |
Output is correct |
69 |
Correct |
5 ms |
340 KB |
Output is correct |
70 |
Correct |
4 ms |
340 KB |
Output is correct |
71 |
Correct |
5 ms |
340 KB |
Output is correct |
72 |
Correct |
6 ms |
340 KB |
Output is correct |
73 |
Correct |
6 ms |
340 KB |
Output is correct |
74 |
Correct |
6 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
304 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
296 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
2 ms |
296 KB |
Output is correct |
27 |
Correct |
2 ms |
212 KB |
Output is correct |
28 |
Correct |
3 ms |
212 KB |
Output is correct |
29 |
Correct |
3 ms |
212 KB |
Output is correct |
30 |
Correct |
4 ms |
312 KB |
Output is correct |
31 |
Correct |
3 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
212 KB |
Output is correct |
33 |
Correct |
3 ms |
212 KB |
Output is correct |
34 |
Correct |
3 ms |
212 KB |
Output is correct |
35 |
Correct |
6 ms |
212 KB |
Output is correct |
36 |
Correct |
8 ms |
340 KB |
Output is correct |
37 |
Correct |
12 ms |
340 KB |
Output is correct |
38 |
Correct |
16 ms |
376 KB |
Output is correct |
39 |
Correct |
17 ms |
380 KB |
Output is correct |
40 |
Correct |
19 ms |
460 KB |
Output is correct |
41 |
Correct |
17 ms |
384 KB |
Output is correct |
42 |
Correct |
20 ms |
340 KB |
Output is correct |
43 |
Correct |
2 ms |
212 KB |
Output is correct |
44 |
Correct |
3 ms |
340 KB |
Output is correct |
45 |
Correct |
4 ms |
340 KB |
Output is correct |
46 |
Correct |
5 ms |
340 KB |
Output is correct |
47 |
Correct |
5 ms |
340 KB |
Output is correct |
48 |
Correct |
5 ms |
372 KB |
Output is correct |
49 |
Correct |
6 ms |
340 KB |
Output is correct |
50 |
Correct |
6 ms |
300 KB |
Output is correct |
51 |
Correct |
1 ms |
212 KB |
Output is correct |
52 |
Correct |
8 ms |
304 KB |
Output is correct |
53 |
Correct |
14 ms |
308 KB |
Output is correct |
54 |
Correct |
24 ms |
212 KB |
Output is correct |
55 |
Correct |
22 ms |
212 KB |
Output is correct |
56 |
Correct |
79 ms |
340 KB |
Output is correct |
57 |
Correct |
78 ms |
328 KB |
Output is correct |
58 |
Correct |
74 ms |
324 KB |
Output is correct |
59 |
Correct |
72 ms |
212 KB |
Output is correct |
60 |
Correct |
83 ms |
344 KB |
Output is correct |
61 |
Correct |
1 ms |
212 KB |
Output is correct |
62 |
Correct |
14 ms |
308 KB |
Output is correct |
63 |
Correct |
24 ms |
308 KB |
Output is correct |
64 |
Correct |
21 ms |
212 KB |
Output is correct |
65 |
Correct |
41 ms |
312 KB |
Output is correct |
66 |
Correct |
58 ms |
212 KB |
Output is correct |
67 |
Correct |
79 ms |
340 KB |
Output is correct |
68 |
Correct |
78 ms |
340 KB |
Output is correct |
69 |
Correct |
77 ms |
320 KB |
Output is correct |