#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a, b;
ll y[100], pref[101];
long long ans = 0;
int firstI = 40;
inline ll rem(ll i, ll cnt){
return ((i>>cnt)<<cnt);
}
bool check(){
vector<vector<bool> > dp(n, vector<bool>(b+1, 0));
dp[0][1] = ((rem(y[0], firstI)|ans) == ans);
for(int i = 1; i < n; i++){
dp[i][1] = ((rem(pref[i+1], firstI)|ans) == ans);
for(int k = 2; k <= b; k++){
ll sum = y[i];
for(int j = i-1; j >= 0 && !dp[i][k]; j--){
dp[i][k] = (dp[j][k-1] && ((rem(sum, firstI)|ans) == ans));
sum += y[j];
}
}
}
// for(int i = 0; i < n; i++){
// for(int j = 0; j <= b; j++){
// cout<<dp[i][j]<<"\t";
// }
// cout<<endl;
// }
// cout<<endl;
for(int i = a; i <= b; i++){
if(dp[n-1][i]) return true;
}
return false;
}
int main(){
cin>>n>>a>>b;
pref[0] = 0;
for(int i = 0; i < n; i++){
cin>>y[i];
pref[i+1] = pref[i] + y[i];
}
ans = (1LL<<firstI)-1;
for(firstI--; firstI >= 0; firstI--){
ans -= (1LL<<firstI);
//cout<<"PRE "<<firstI<<" : "<<ans<<endl;
if(!check()){
//cout<<"NO"<<endl;
ans += (1LL<<(firstI));
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
528 KB |
Output is correct |
5 |
Correct |
3 ms |
528 KB |
Output is correct |
6 |
Correct |
3 ms |
552 KB |
Output is correct |
7 |
Correct |
3 ms |
552 KB |
Output is correct |
8 |
Correct |
3 ms |
552 KB |
Output is correct |
9 |
Correct |
2 ms |
600 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
652 KB |
Output is correct |
13 |
Correct |
3 ms |
712 KB |
Output is correct |
14 |
Correct |
3 ms |
712 KB |
Output is correct |
15 |
Correct |
2 ms |
712 KB |
Output is correct |
16 |
Correct |
3 ms |
712 KB |
Output is correct |
17 |
Correct |
2 ms |
712 KB |
Output is correct |
18 |
Correct |
3 ms |
712 KB |
Output is correct |
19 |
Correct |
3 ms |
712 KB |
Output is correct |
20 |
Correct |
2 ms |
712 KB |
Output is correct |
21 |
Correct |
3 ms |
712 KB |
Output is correct |
22 |
Correct |
3 ms |
712 KB |
Output is correct |
23 |
Correct |
3 ms |
712 KB |
Output is correct |
24 |
Correct |
3 ms |
760 KB |
Output is correct |
25 |
Correct |
3 ms |
760 KB |
Output is correct |
26 |
Correct |
3 ms |
760 KB |
Output is correct |
27 |
Correct |
3 ms |
760 KB |
Output is correct |
28 |
Correct |
3 ms |
760 KB |
Output is correct |
29 |
Correct |
3 ms |
776 KB |
Output is correct |
30 |
Correct |
4 ms |
776 KB |
Output is correct |
31 |
Correct |
3 ms |
776 KB |
Output is correct |
32 |
Correct |
3 ms |
820 KB |
Output is correct |
33 |
Correct |
3 ms |
820 KB |
Output is correct |
34 |
Correct |
4 ms |
820 KB |
Output is correct |
35 |
Correct |
4 ms |
820 KB |
Output is correct |
36 |
Correct |
4 ms |
820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
820 KB |
Output is correct |
2 |
Correct |
3 ms |
820 KB |
Output is correct |
3 |
Correct |
2 ms |
820 KB |
Output is correct |
4 |
Correct |
3 ms |
820 KB |
Output is correct |
5 |
Correct |
3 ms |
820 KB |
Output is correct |
6 |
Correct |
4 ms |
820 KB |
Output is correct |
7 |
Correct |
3 ms |
820 KB |
Output is correct |
8 |
Correct |
4 ms |
820 KB |
Output is correct |
9 |
Correct |
3 ms |
820 KB |
Output is correct |
10 |
Correct |
3 ms |
820 KB |
Output is correct |
11 |
Correct |
3 ms |
820 KB |
Output is correct |
12 |
Correct |
3 ms |
820 KB |
Output is correct |
13 |
Correct |
2 ms |
820 KB |
Output is correct |
14 |
Correct |
2 ms |
820 KB |
Output is correct |
15 |
Correct |
2 ms |
820 KB |
Output is correct |
16 |
Correct |
2 ms |
820 KB |
Output is correct |
17 |
Correct |
2 ms |
820 KB |
Output is correct |
18 |
Correct |
2 ms |
820 KB |
Output is correct |
19 |
Correct |
2 ms |
948 KB |
Output is correct |
20 |
Correct |
2 ms |
948 KB |
Output is correct |
21 |
Correct |
2 ms |
948 KB |
Output is correct |
22 |
Correct |
2 ms |
948 KB |
Output is correct |
23 |
Correct |
3 ms |
948 KB |
Output is correct |
24 |
Correct |
2 ms |
948 KB |
Output is correct |
25 |
Correct |
4 ms |
948 KB |
Output is correct |
26 |
Correct |
3 ms |
948 KB |
Output is correct |
27 |
Correct |
3 ms |
948 KB |
Output is correct |
28 |
Correct |
3 ms |
992 KB |
Output is correct |
29 |
Correct |
3 ms |
992 KB |
Output is correct |
30 |
Correct |
3 ms |
1000 KB |
Output is correct |
31 |
Correct |
5 ms |
1000 KB |
Output is correct |
32 |
Correct |
3 ms |
1000 KB |
Output is correct |
33 |
Correct |
3 ms |
1000 KB |
Output is correct |
34 |
Correct |
5 ms |
1000 KB |
Output is correct |
35 |
Correct |
3 ms |
1000 KB |
Output is correct |
36 |
Correct |
3 ms |
1000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1072 KB |
Output is correct |
2 |
Correct |
3 ms |
1076 KB |
Output is correct |
3 |
Correct |
3 ms |
1080 KB |
Output is correct |
4 |
Correct |
2 ms |
1084 KB |
Output is correct |
5 |
Correct |
2 ms |
1088 KB |
Output is correct |
6 |
Correct |
2 ms |
1092 KB |
Output is correct |
7 |
Correct |
2 ms |
1096 KB |
Output is correct |
8 |
Correct |
3 ms |
1100 KB |
Output is correct |
9 |
Correct |
2 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
1216 KB |
Output is correct |
11 |
Correct |
3 ms |
1216 KB |
Output is correct |
12 |
Correct |
3 ms |
1216 KB |
Output is correct |
13 |
Correct |
3 ms |
1216 KB |
Output is correct |
14 |
Correct |
3 ms |
1216 KB |
Output is correct |
15 |
Correct |
4 ms |
1216 KB |
Output is correct |
16 |
Correct |
3 ms |
1216 KB |
Output is correct |
17 |
Correct |
4 ms |
1216 KB |
Output is correct |
18 |
Correct |
3 ms |
1260 KB |
Output is correct |
19 |
Correct |
4 ms |
1260 KB |
Output is correct |
20 |
Correct |
3 ms |
1260 KB |
Output is correct |
21 |
Correct |
3 ms |
1260 KB |
Output is correct |
22 |
Correct |
3 ms |
1260 KB |
Output is correct |
23 |
Correct |
3 ms |
1260 KB |
Output is correct |
24 |
Correct |
4 ms |
1260 KB |
Output is correct |
25 |
Correct |
3 ms |
1260 KB |
Output is correct |
26 |
Correct |
6 ms |
1260 KB |
Output is correct |
27 |
Correct |
12 ms |
1260 KB |
Output is correct |
28 |
Correct |
28 ms |
1260 KB |
Output is correct |
29 |
Correct |
28 ms |
1340 KB |
Output is correct |
30 |
Correct |
3 ms |
1344 KB |
Output is correct |
31 |
Correct |
10 ms |
1348 KB |
Output is correct |
32 |
Correct |
17 ms |
1348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1348 KB |
Output is correct |
2 |
Correct |
2 ms |
1360 KB |
Output is correct |
3 |
Correct |
3 ms |
1360 KB |
Output is correct |
4 |
Correct |
3 ms |
1360 KB |
Output is correct |
5 |
Correct |
4 ms |
1360 KB |
Output is correct |
6 |
Correct |
2 ms |
1360 KB |
Output is correct |
7 |
Correct |
3 ms |
1384 KB |
Output is correct |
8 |
Correct |
2 ms |
1384 KB |
Output is correct |
9 |
Correct |
3 ms |
1384 KB |
Output is correct |
10 |
Correct |
3 ms |
1384 KB |
Output is correct |
11 |
Correct |
2 ms |
1384 KB |
Output is correct |
12 |
Correct |
2 ms |
1384 KB |
Output is correct |
13 |
Correct |
4 ms |
1384 KB |
Output is correct |
14 |
Correct |
2 ms |
1384 KB |
Output is correct |
15 |
Correct |
3 ms |
1384 KB |
Output is correct |
16 |
Correct |
3 ms |
1384 KB |
Output is correct |
17 |
Correct |
3 ms |
1384 KB |
Output is correct |
18 |
Correct |
3 ms |
1384 KB |
Output is correct |
19 |
Correct |
3 ms |
1384 KB |
Output is correct |
20 |
Correct |
3 ms |
1384 KB |
Output is correct |
21 |
Correct |
3 ms |
1384 KB |
Output is correct |
22 |
Correct |
3 ms |
1384 KB |
Output is correct |
23 |
Correct |
3 ms |
1384 KB |
Output is correct |
24 |
Correct |
3 ms |
1384 KB |
Output is correct |
25 |
Correct |
3 ms |
1384 KB |
Output is correct |
26 |
Correct |
2 ms |
1384 KB |
Output is correct |
27 |
Correct |
3 ms |
1384 KB |
Output is correct |
28 |
Correct |
3 ms |
1384 KB |
Output is correct |
29 |
Correct |
3 ms |
1384 KB |
Output is correct |
30 |
Correct |
3 ms |
1384 KB |
Output is correct |
31 |
Correct |
3 ms |
1384 KB |
Output is correct |
32 |
Correct |
3 ms |
1384 KB |
Output is correct |
33 |
Correct |
3 ms |
1384 KB |
Output is correct |
34 |
Correct |
3 ms |
1384 KB |
Output is correct |
35 |
Correct |
3 ms |
1384 KB |
Output is correct |
36 |
Correct |
3 ms |
1508 KB |
Output is correct |
37 |
Correct |
3 ms |
1508 KB |
Output is correct |
38 |
Correct |
2 ms |
1508 KB |
Output is correct |
39 |
Correct |
3 ms |
1532 KB |
Output is correct |
40 |
Correct |
3 ms |
1532 KB |
Output is correct |
41 |
Correct |
4 ms |
1532 KB |
Output is correct |
42 |
Correct |
4 ms |
1532 KB |
Output is correct |
43 |
Correct |
3 ms |
1532 KB |
Output is correct |
44 |
Correct |
4 ms |
1532 KB |
Output is correct |
45 |
Correct |
3 ms |
1532 KB |
Output is correct |
46 |
Correct |
3 ms |
1532 KB |
Output is correct |
47 |
Correct |
3 ms |
1532 KB |
Output is correct |
48 |
Correct |
4 ms |
1532 KB |
Output is correct |
49 |
Correct |
4 ms |
1532 KB |
Output is correct |
50 |
Correct |
10 ms |
1532 KB |
Output is correct |
51 |
Correct |
30 ms |
1532 KB |
Output is correct |
52 |
Correct |
29 ms |
1532 KB |
Output is correct |
53 |
Correct |
3 ms |
1532 KB |
Output is correct |
54 |
Correct |
10 ms |
1532 KB |
Output is correct |
55 |
Correct |
18 ms |
1532 KB |
Output is correct |
56 |
Correct |
5 ms |
1532 KB |
Output is correct |
57 |
Correct |
11 ms |
1532 KB |
Output is correct |
58 |
Correct |
26 ms |
1616 KB |
Output is correct |
59 |
Correct |
56 ms |
1616 KB |
Output is correct |
60 |
Correct |
59 ms |
1756 KB |
Output is correct |
61 |
Correct |
3 ms |
1764 KB |
Output is correct |
62 |
Correct |
50 ms |
1764 KB |
Output is correct |
63 |
Correct |
48 ms |
1764 KB |
Output is correct |
64 |
Correct |
19 ms |
1764 KB |
Output is correct |
65 |
Correct |
5 ms |
1764 KB |
Output is correct |
66 |
Correct |
6 ms |
1764 KB |
Output is correct |
67 |
Correct |
9 ms |
1764 KB |
Output is correct |
68 |
Correct |
24 ms |
1764 KB |
Output is correct |
69 |
Correct |
49 ms |
1764 KB |
Output is correct |
70 |
Correct |
50 ms |
1764 KB |
Output is correct |
71 |
Correct |
4 ms |
1764 KB |
Output is correct |
72 |
Correct |
51 ms |
1764 KB |
Output is correct |
73 |
Correct |
35 ms |
1764 KB |
Output is correct |
74 |
Correct |
32 ms |
1764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1764 KB |
Output is correct |
2 |
Correct |
2 ms |
1764 KB |
Output is correct |
3 |
Correct |
3 ms |
1764 KB |
Output is correct |
4 |
Correct |
3 ms |
1764 KB |
Output is correct |
5 |
Correct |
2 ms |
1764 KB |
Output is correct |
6 |
Correct |
3 ms |
1764 KB |
Output is correct |
7 |
Correct |
3 ms |
1764 KB |
Output is correct |
8 |
Correct |
4 ms |
1764 KB |
Output is correct |
9 |
Correct |
3 ms |
1764 KB |
Output is correct |
10 |
Correct |
2 ms |
1764 KB |
Output is correct |
11 |
Correct |
3 ms |
1764 KB |
Output is correct |
12 |
Correct |
5 ms |
1812 KB |
Output is correct |
13 |
Correct |
3 ms |
1812 KB |
Output is correct |
14 |
Correct |
2 ms |
1812 KB |
Output is correct |
15 |
Correct |
3 ms |
1812 KB |
Output is correct |
16 |
Correct |
3 ms |
1812 KB |
Output is correct |
17 |
Correct |
3 ms |
1812 KB |
Output is correct |
18 |
Correct |
2 ms |
1812 KB |
Output is correct |
19 |
Correct |
2 ms |
1812 KB |
Output is correct |
20 |
Correct |
4 ms |
1812 KB |
Output is correct |
21 |
Correct |
3 ms |
1812 KB |
Output is correct |
22 |
Correct |
3 ms |
1812 KB |
Output is correct |
23 |
Correct |
4 ms |
1812 KB |
Output is correct |
24 |
Correct |
3 ms |
1812 KB |
Output is correct |
25 |
Correct |
4 ms |
1812 KB |
Output is correct |
26 |
Correct |
3 ms |
1812 KB |
Output is correct |
27 |
Correct |
4 ms |
1812 KB |
Output is correct |
28 |
Correct |
5 ms |
1812 KB |
Output is correct |
29 |
Correct |
4 ms |
1812 KB |
Output is correct |
30 |
Correct |
2 ms |
1812 KB |
Output is correct |
31 |
Correct |
4 ms |
1812 KB |
Output is correct |
32 |
Correct |
4 ms |
1904 KB |
Output is correct |
33 |
Correct |
4 ms |
1904 KB |
Output is correct |
34 |
Correct |
3 ms |
1904 KB |
Output is correct |
35 |
Correct |
3 ms |
1904 KB |
Output is correct |
36 |
Correct |
5 ms |
1904 KB |
Output is correct |
37 |
Correct |
10 ms |
1904 KB |
Output is correct |
38 |
Correct |
27 ms |
1904 KB |
Output is correct |
39 |
Correct |
29 ms |
1904 KB |
Output is correct |
40 |
Correct |
3 ms |
1928 KB |
Output is correct |
41 |
Correct |
12 ms |
1932 KB |
Output is correct |
42 |
Correct |
16 ms |
1936 KB |
Output is correct |
43 |
Correct |
7 ms |
1936 KB |
Output is correct |
44 |
Correct |
10 ms |
1936 KB |
Output is correct |
45 |
Correct |
25 ms |
1936 KB |
Output is correct |
46 |
Correct |
50 ms |
1952 KB |
Output is correct |
47 |
Correct |
57 ms |
1956 KB |
Output is correct |
48 |
Correct |
3 ms |
1956 KB |
Output is correct |
49 |
Correct |
59 ms |
1968 KB |
Output is correct |
50 |
Correct |
50 ms |
1992 KB |
Output is correct |
51 |
Runtime error |
1002 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
52 |
Halted |
0 ms |
0 KB |
- |