#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
ll n,a,b;
vi y;
bool possible(ll forbiddenBits){
//cout<<forbiddenBits<<": "<<endl;
vector<vector<bool> > dp(n+1,vector<bool>(n+1,false)); //dp[numGroups][index];
rep(i,a,b+1) dp[i][n] = true;
for(ll i = n-1;i>=0;--i){
rep(numGroups,0,n){
ll sum = 0;
rep(j,i+1,n+1){
sum += y[j-1];
dp[numGroups][i] = (dp[numGroups][i]|(((sum&forbiddenBits)==0)&&(dp[numGroups+1][j])));
}
//cout<<dp[numGroups][i];
}
// cout<<endl;
}
return dp[0][0];
}
int main(){
cin.sync_with_stdio(false);
cin>>n>>a>>b;
y.resize(n);
rep(i,0,n) cin>>y[i];
ll ans = 0;
ll forbiddenBits = 0;
for(ll i = 60; i>=0;--i){
forbiddenBits |= (1LL<<i);
if(!possible(forbiddenBits))
forbiddenBits ^= (1LL<<i);
//cout<<((forbiddenBits&(1LL<<i))>0);
if(!(forbiddenBits&(1LL<<i)))
ans |= (1LL<<i);
}
//cout<<endl;
cout<<ans<<endl;
//cout<<possible(2305843009213693942ll)<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
3 ms |
488 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
560 KB |
Output is correct |
7 |
Correct |
4 ms |
560 KB |
Output is correct |
8 |
Correct |
3 ms |
564 KB |
Output is correct |
9 |
Correct |
5 ms |
572 KB |
Output is correct |
10 |
Correct |
4 ms |
624 KB |
Output is correct |
11 |
Correct |
5 ms |
628 KB |
Output is correct |
12 |
Correct |
4 ms |
688 KB |
Output is correct |
13 |
Correct |
4 ms |
692 KB |
Output is correct |
14 |
Correct |
3 ms |
696 KB |
Output is correct |
15 |
Correct |
3 ms |
700 KB |
Output is correct |
16 |
Correct |
3 ms |
768 KB |
Output is correct |
17 |
Correct |
3 ms |
772 KB |
Output is correct |
18 |
Correct |
4 ms |
772 KB |
Output is correct |
19 |
Correct |
3 ms |
784 KB |
Output is correct |
20 |
Correct |
5 ms |
784 KB |
Output is correct |
21 |
Correct |
4 ms |
784 KB |
Output is correct |
22 |
Correct |
2 ms |
788 KB |
Output is correct |
23 |
Correct |
4 ms |
792 KB |
Output is correct |
24 |
Correct |
4 ms |
796 KB |
Output is correct |
25 |
Correct |
3 ms |
928 KB |
Output is correct |
26 |
Correct |
5 ms |
928 KB |
Output is correct |
27 |
Correct |
3 ms |
928 KB |
Output is correct |
28 |
Correct |
3 ms |
928 KB |
Output is correct |
29 |
Correct |
4 ms |
928 KB |
Output is correct |
30 |
Correct |
4 ms |
928 KB |
Output is correct |
31 |
Correct |
4 ms |
928 KB |
Output is correct |
32 |
Correct |
4 ms |
928 KB |
Output is correct |
33 |
Correct |
4 ms |
928 KB |
Output is correct |
34 |
Correct |
4 ms |
928 KB |
Output is correct |
35 |
Correct |
4 ms |
928 KB |
Output is correct |
36 |
Correct |
6 ms |
928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
928 KB |
Output is correct |
2 |
Correct |
3 ms |
928 KB |
Output is correct |
3 |
Correct |
2 ms |
928 KB |
Output is correct |
4 |
Correct |
2 ms |
928 KB |
Output is correct |
5 |
Correct |
3 ms |
928 KB |
Output is correct |
6 |
Correct |
3 ms |
988 KB |
Output is correct |
7 |
Correct |
3 ms |
988 KB |
Output is correct |
8 |
Correct |
4 ms |
988 KB |
Output is correct |
9 |
Correct |
4 ms |
988 KB |
Output is correct |
10 |
Correct |
4 ms |
988 KB |
Output is correct |
11 |
Correct |
3 ms |
988 KB |
Output is correct |
12 |
Correct |
4 ms |
988 KB |
Output is correct |
13 |
Correct |
4 ms |
988 KB |
Output is correct |
14 |
Correct |
3 ms |
988 KB |
Output is correct |
15 |
Correct |
3 ms |
988 KB |
Output is correct |
16 |
Correct |
3 ms |
988 KB |
Output is correct |
17 |
Correct |
2 ms |
988 KB |
Output is correct |
18 |
Correct |
3 ms |
988 KB |
Output is correct |
19 |
Correct |
5 ms |
988 KB |
Output is correct |
20 |
Correct |
4 ms |
988 KB |
Output is correct |
21 |
Correct |
5 ms |
988 KB |
Output is correct |
22 |
Correct |
3 ms |
988 KB |
Output is correct |
23 |
Correct |
4 ms |
988 KB |
Output is correct |
24 |
Correct |
4 ms |
988 KB |
Output is correct |
25 |
Correct |
4 ms |
988 KB |
Output is correct |
26 |
Correct |
4 ms |
988 KB |
Output is correct |
27 |
Correct |
5 ms |
988 KB |
Output is correct |
28 |
Correct |
5 ms |
988 KB |
Output is correct |
29 |
Correct |
8 ms |
988 KB |
Output is correct |
30 |
Correct |
11 ms |
988 KB |
Output is correct |
31 |
Correct |
18 ms |
988 KB |
Output is correct |
32 |
Correct |
22 ms |
988 KB |
Output is correct |
33 |
Correct |
19 ms |
988 KB |
Output is correct |
34 |
Correct |
24 ms |
988 KB |
Output is correct |
35 |
Correct |
17 ms |
988 KB |
Output is correct |
36 |
Correct |
17 ms |
988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
988 KB |
Output is correct |
2 |
Correct |
3 ms |
988 KB |
Output is correct |
3 |
Correct |
2 ms |
988 KB |
Output is correct |
4 |
Correct |
4 ms |
988 KB |
Output is correct |
5 |
Correct |
2 ms |
996 KB |
Output is correct |
6 |
Correct |
3 ms |
996 KB |
Output is correct |
7 |
Correct |
4 ms |
1016 KB |
Output is correct |
8 |
Correct |
4 ms |
1016 KB |
Output is correct |
9 |
Correct |
4 ms |
1016 KB |
Output is correct |
10 |
Correct |
4 ms |
1016 KB |
Output is correct |
11 |
Correct |
4 ms |
1016 KB |
Output is correct |
12 |
Correct |
4 ms |
1016 KB |
Output is correct |
13 |
Correct |
5 ms |
1024 KB |
Output is correct |
14 |
Correct |
4 ms |
1028 KB |
Output is correct |
15 |
Correct |
6 ms |
1036 KB |
Output is correct |
16 |
Correct |
12 ms |
1036 KB |
Output is correct |
17 |
Correct |
11 ms |
1040 KB |
Output is correct |
18 |
Correct |
15 ms |
1044 KB |
Output is correct |
19 |
Correct |
17 ms |
1048 KB |
Output is correct |
20 |
Correct |
18 ms |
1064 KB |
Output is correct |
21 |
Correct |
16 ms |
1064 KB |
Output is correct |
22 |
Correct |
15 ms |
1200 KB |
Output is correct |
23 |
Correct |
17 ms |
1200 KB |
Output is correct |
24 |
Correct |
17 ms |
1200 KB |
Output is correct |
25 |
Correct |
33 ms |
1200 KB |
Output is correct |
26 |
Correct |
51 ms |
1200 KB |
Output is correct |
27 |
Correct |
113 ms |
1200 KB |
Output is correct |
28 |
Correct |
102 ms |
1200 KB |
Output is correct |
29 |
Correct |
130 ms |
1200 KB |
Output is correct |
30 |
Correct |
104 ms |
1200 KB |
Output is correct |
31 |
Correct |
104 ms |
1200 KB |
Output is correct |
32 |
Correct |
109 ms |
1200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1200 KB |
Output is correct |
2 |
Correct |
3 ms |
1200 KB |
Output is correct |
3 |
Correct |
2 ms |
1200 KB |
Output is correct |
4 |
Correct |
2 ms |
1200 KB |
Output is correct |
5 |
Correct |
3 ms |
1200 KB |
Output is correct |
6 |
Correct |
3 ms |
1200 KB |
Output is correct |
7 |
Correct |
5 ms |
1200 KB |
Output is correct |
8 |
Correct |
5 ms |
1200 KB |
Output is correct |
9 |
Correct |
4 ms |
1200 KB |
Output is correct |
10 |
Correct |
4 ms |
1200 KB |
Output is correct |
11 |
Correct |
4 ms |
1200 KB |
Output is correct |
12 |
Correct |
5 ms |
1200 KB |
Output is correct |
13 |
Correct |
4 ms |
1200 KB |
Output is correct |
14 |
Correct |
3 ms |
1200 KB |
Output is correct |
15 |
Correct |
4 ms |
1200 KB |
Output is correct |
16 |
Correct |
3 ms |
1200 KB |
Output is correct |
17 |
Correct |
3 ms |
1200 KB |
Output is correct |
18 |
Correct |
3 ms |
1200 KB |
Output is correct |
19 |
Correct |
4 ms |
1200 KB |
Output is correct |
20 |
Correct |
5 ms |
1200 KB |
Output is correct |
21 |
Correct |
5 ms |
1200 KB |
Output is correct |
22 |
Correct |
3 ms |
1200 KB |
Output is correct |
23 |
Correct |
5 ms |
1200 KB |
Output is correct |
24 |
Correct |
4 ms |
1200 KB |
Output is correct |
25 |
Correct |
5 ms |
1200 KB |
Output is correct |
26 |
Correct |
4 ms |
1204 KB |
Output is correct |
27 |
Correct |
3 ms |
1208 KB |
Output is correct |
28 |
Correct |
4 ms |
1212 KB |
Output is correct |
29 |
Correct |
4 ms |
1216 KB |
Output is correct |
30 |
Correct |
5 ms |
1220 KB |
Output is correct |
31 |
Correct |
4 ms |
1224 KB |
Output is correct |
32 |
Correct |
3 ms |
1236 KB |
Output is correct |
33 |
Correct |
5 ms |
1236 KB |
Output is correct |
34 |
Correct |
5 ms |
1240 KB |
Output is correct |
35 |
Correct |
4 ms |
1240 KB |
Output is correct |
36 |
Correct |
4 ms |
1244 KB |
Output is correct |
37 |
Correct |
5 ms |
1248 KB |
Output is correct |
38 |
Correct |
5 ms |
1264 KB |
Output is correct |
39 |
Correct |
12 ms |
1264 KB |
Output is correct |
40 |
Correct |
12 ms |
1264 KB |
Output is correct |
41 |
Correct |
22 ms |
1264 KB |
Output is correct |
42 |
Correct |
20 ms |
1272 KB |
Output is correct |
43 |
Correct |
16 ms |
1280 KB |
Output is correct |
44 |
Correct |
23 ms |
1288 KB |
Output is correct |
45 |
Correct |
17 ms |
1288 KB |
Output is correct |
46 |
Correct |
25 ms |
1300 KB |
Output is correct |
47 |
Correct |
20 ms |
1300 KB |
Output is correct |
48 |
Correct |
31 ms |
1300 KB |
Output is correct |
49 |
Correct |
59 ms |
1464 KB |
Output is correct |
50 |
Correct |
90 ms |
1464 KB |
Output is correct |
51 |
Correct |
144 ms |
1464 KB |
Output is correct |
52 |
Correct |
105 ms |
1464 KB |
Output is correct |
53 |
Correct |
108 ms |
1464 KB |
Output is correct |
54 |
Correct |
99 ms |
1464 KB |
Output is correct |
55 |
Correct |
109 ms |
1464 KB |
Output is correct |
56 |
Correct |
22 ms |
1464 KB |
Output is correct |
57 |
Correct |
53 ms |
1464 KB |
Output is correct |
58 |
Correct |
73 ms |
1500 KB |
Output is correct |
59 |
Correct |
94 ms |
1500 KB |
Output is correct |
60 |
Correct |
99 ms |
1544 KB |
Output is correct |
61 |
Correct |
118 ms |
1544 KB |
Output is correct |
62 |
Correct |
107 ms |
1544 KB |
Output is correct |
63 |
Correct |
102 ms |
1544 KB |
Output is correct |
64 |
Correct |
84 ms |
1544 KB |
Output is correct |
65 |
Correct |
17 ms |
1544 KB |
Output is correct |
66 |
Correct |
29 ms |
1544 KB |
Output is correct |
67 |
Correct |
56 ms |
1544 KB |
Output is correct |
68 |
Correct |
76 ms |
1544 KB |
Output is correct |
69 |
Correct |
106 ms |
1544 KB |
Output is correct |
70 |
Correct |
100 ms |
1544 KB |
Output is correct |
71 |
Correct |
107 ms |
1544 KB |
Output is correct |
72 |
Correct |
96 ms |
1544 KB |
Output is correct |
73 |
Correct |
94 ms |
1644 KB |
Output is correct |
74 |
Correct |
92 ms |
1644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1644 KB |
Output is correct |
2 |
Correct |
2 ms |
1644 KB |
Output is correct |
3 |
Correct |
2 ms |
1644 KB |
Output is correct |
4 |
Correct |
4 ms |
1644 KB |
Output is correct |
5 |
Correct |
3 ms |
1644 KB |
Output is correct |
6 |
Correct |
3 ms |
1644 KB |
Output is correct |
7 |
Correct |
3 ms |
1644 KB |
Output is correct |
8 |
Correct |
4 ms |
1644 KB |
Output is correct |
9 |
Correct |
4 ms |
1644 KB |
Output is correct |
10 |
Correct |
4 ms |
1644 KB |
Output is correct |
11 |
Correct |
5 ms |
1644 KB |
Output is correct |
12 |
Correct |
5 ms |
1644 KB |
Output is correct |
13 |
Correct |
1 ms |
1644 KB |
Output is correct |
14 |
Correct |
2 ms |
1644 KB |
Output is correct |
15 |
Correct |
2 ms |
1644 KB |
Output is correct |
16 |
Correct |
3 ms |
1644 KB |
Output is correct |
17 |
Correct |
3 ms |
1644 KB |
Output is correct |
18 |
Correct |
4 ms |
1644 KB |
Output is correct |
19 |
Correct |
3 ms |
1644 KB |
Output is correct |
20 |
Correct |
4 ms |
1644 KB |
Output is correct |
21 |
Correct |
3 ms |
1644 KB |
Output is correct |
22 |
Correct |
5 ms |
1644 KB |
Output is correct |
23 |
Correct |
3 ms |
1644 KB |
Output is correct |
24 |
Correct |
4 ms |
1644 KB |
Output is correct |
25 |
Correct |
6 ms |
1644 KB |
Output is correct |
26 |
Correct |
12 ms |
1644 KB |
Output is correct |
27 |
Correct |
13 ms |
1644 KB |
Output is correct |
28 |
Correct |
24 ms |
1644 KB |
Output is correct |
29 |
Correct |
23 ms |
1644 KB |
Output is correct |
30 |
Correct |
22 ms |
1644 KB |
Output is correct |
31 |
Correct |
17 ms |
1644 KB |
Output is correct |
32 |
Correct |
17 ms |
1680 KB |
Output is correct |
33 |
Correct |
17 ms |
1680 KB |
Output is correct |
34 |
Correct |
19 ms |
1688 KB |
Output is correct |
35 |
Correct |
35 ms |
1688 KB |
Output is correct |
36 |
Correct |
73 ms |
1688 KB |
Output is correct |
37 |
Correct |
80 ms |
1688 KB |
Output is correct |
38 |
Correct |
119 ms |
1688 KB |
Output is correct |
39 |
Correct |
116 ms |
1688 KB |
Output is correct |
40 |
Correct |
141 ms |
1688 KB |
Output is correct |
41 |
Correct |
110 ms |
1688 KB |
Output is correct |
42 |
Correct |
104 ms |
1688 KB |
Output is correct |
43 |
Correct |
21 ms |
1688 KB |
Output is correct |
44 |
Correct |
67 ms |
1688 KB |
Output is correct |
45 |
Correct |
80 ms |
1688 KB |
Output is correct |
46 |
Correct |
105 ms |
1688 KB |
Output is correct |
47 |
Correct |
99 ms |
1688 KB |
Output is correct |
48 |
Correct |
111 ms |
1688 KB |
Output is correct |
49 |
Correct |
95 ms |
1756 KB |
Output is correct |
50 |
Correct |
106 ms |
1760 KB |
Output is correct |
51 |
Correct |
119 ms |
1760 KB |
Output is correct |
52 |
Execution timed out |
1083 ms |
1760 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |