#include <bits/stdc++.h>
#define ll long long
using namespace std;
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<" - ", _do(__VA_ARGS__)
template<typename T> void _do(T && x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#endif // BALBIT
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x.size())
#define pb push_back
bool dp[102][102];
signed main(){
IOS();
int n; cin>>n;
vector<ll> ps(n+1);
int A, B; cin>>A>>B;
for (int i = 0; i<n; ++i) {
cin>>ps[i+1]; ps[i+1] += ps[i];
}
ll BAD = 0;
ll ANS = 0;
for (int bt = 40; bt >= 0; -- bt) {
BAD |= (1ll<<bt);
memset(dp, 0, sizeof dp);
dp[0][0] = 1;
bool ok = 0;
for (int i = 1; i<=n; ++i) {
for (int k = 1; k <=n; ++k) {
for (int j = 0; j<i; ++j) {
if (((ps[i] - ps[j]) & BAD) == 0 && dp[j][k-1]) {
dp[i][k] =1; break;
}
}
if (dp[i][k] && i == n && k >= A && k <= B) {
ok = 1; break;
}
}
}
if (!ok) {
BAD ^= (1ll<<bt);
ANS |= (1ll<<bt);
}
}
cout<<ANS<<endl;
}
/*
6 1 3
8 1 2 1 5 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
5 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
6 ms |
384 KB |
Output is correct |
30 |
Correct |
6 ms |
384 KB |
Output is correct |
31 |
Correct |
7 ms |
384 KB |
Output is correct |
32 |
Correct |
8 ms |
384 KB |
Output is correct |
33 |
Correct |
7 ms |
384 KB |
Output is correct |
34 |
Correct |
7 ms |
384 KB |
Output is correct |
35 |
Correct |
7 ms |
384 KB |
Output is correct |
36 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
8 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
384 KB |
Output is correct |
20 |
Correct |
7 ms |
384 KB |
Output is correct |
21 |
Correct |
7 ms |
384 KB |
Output is correct |
22 |
Correct |
7 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
7 ms |
384 KB |
Output is correct |
25 |
Correct |
10 ms |
384 KB |
Output is correct |
26 |
Correct |
14 ms |
384 KB |
Output is correct |
27 |
Correct |
19 ms |
384 KB |
Output is correct |
28 |
Correct |
24 ms |
384 KB |
Output is correct |
29 |
Correct |
24 ms |
384 KB |
Output is correct |
30 |
Correct |
23 ms |
384 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
304 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
29 |
Correct |
5 ms |
384 KB |
Output is correct |
30 |
Correct |
5 ms |
384 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
33 |
Correct |
5 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 |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
5 ms |
384 KB |
Output is correct |
39 |
Correct |
6 ms |
384 KB |
Output is correct |
40 |
Correct |
6 ms |
384 KB |
Output is correct |
41 |
Correct |
7 ms |
384 KB |
Output is correct |
42 |
Correct |
7 ms |
384 KB |
Output is correct |
43 |
Correct |
7 ms |
384 KB |
Output is correct |
44 |
Correct |
8 ms |
384 KB |
Output is correct |
45 |
Correct |
7 ms |
384 KB |
Output is correct |
46 |
Correct |
7 ms |
384 KB |
Output is correct |
47 |
Correct |
7 ms |
384 KB |
Output is correct |
48 |
Correct |
10 ms |
384 KB |
Output is correct |
49 |
Correct |
14 ms |
384 KB |
Output is correct |
50 |
Correct |
19 ms |
384 KB |
Output is correct |
51 |
Correct |
24 ms |
384 KB |
Output is correct |
52 |
Correct |
23 ms |
384 KB |
Output is correct |
53 |
Correct |
22 ms |
384 KB |
Output is correct |
54 |
Correct |
29 ms |
384 KB |
Output is correct |
55 |
Correct |
25 ms |
384 KB |
Output is correct |
56 |
Correct |
10 ms |
384 KB |
Output is correct |
57 |
Correct |
19 ms |
384 KB |
Output is correct |
58 |
Correct |
27 ms |
384 KB |
Output is correct |
59 |
Correct |
32 ms |
384 KB |
Output is correct |
60 |
Correct |
35 ms |
384 KB |
Output is correct |
61 |
Correct |
34 ms |
384 KB |
Output is correct |
62 |
Correct |
33 ms |
384 KB |
Output is correct |
63 |
Correct |
33 ms |
384 KB |
Output is correct |
64 |
Correct |
18 ms |
384 KB |
Output is correct |
65 |
Correct |
9 ms |
384 KB |
Output is correct |
66 |
Correct |
13 ms |
384 KB |
Output is correct |
67 |
Correct |
20 ms |
384 KB |
Output is correct |
68 |
Correct |
30 ms |
384 KB |
Output is correct |
69 |
Correct |
34 ms |
384 KB |
Output is correct |
70 |
Correct |
34 ms |
504 KB |
Output is correct |
71 |
Correct |
34 ms |
384 KB |
Output is correct |
72 |
Correct |
32 ms |
384 KB |
Output is correct |
73 |
Correct |
33 ms |
384 KB |
Output is correct |
74 |
Correct |
34 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
256 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
7 ms |
384 KB |
Output is correct |
29 |
Correct |
7 ms |
384 KB |
Output is correct |
30 |
Correct |
7 ms |
384 KB |
Output is correct |
31 |
Correct |
7 ms |
384 KB |
Output is correct |
32 |
Correct |
7 ms |
384 KB |
Output is correct |
33 |
Correct |
7 ms |
384 KB |
Output is correct |
34 |
Correct |
7 ms |
384 KB |
Output is correct |
35 |
Correct |
10 ms |
384 KB |
Output is correct |
36 |
Correct |
14 ms |
384 KB |
Output is correct |
37 |
Correct |
19 ms |
384 KB |
Output is correct |
38 |
Correct |
24 ms |
384 KB |
Output is correct |
39 |
Correct |
24 ms |
384 KB |
Output is correct |
40 |
Correct |
23 ms |
512 KB |
Output is correct |
41 |
Correct |
24 ms |
384 KB |
Output is correct |
42 |
Correct |
24 ms |
384 KB |
Output is correct |
43 |
Correct |
9 ms |
384 KB |
Output is correct |
44 |
Correct |
19 ms |
384 KB |
Output is correct |
45 |
Correct |
26 ms |
384 KB |
Output is correct |
46 |
Correct |
43 ms |
384 KB |
Output is correct |
47 |
Correct |
32 ms |
384 KB |
Output is correct |
48 |
Correct |
32 ms |
384 KB |
Output is correct |
49 |
Correct |
33 ms |
384 KB |
Output is correct |
50 |
Correct |
34 ms |
384 KB |
Output is correct |
51 |
Correct |
34 ms |
384 KB |
Output is correct |
52 |
Runtime error |
13 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |