#include <bits/stdc++.h>
using namespace std;
long long int dp [50][210][210];
long long int dp2 [50][2010];
long long int l [2010];
long long int pref [2010];
int main (){
int n, gra, grb; cin >> n >> gra >> grb;
if (gra==1){
for (int i=0; i<50; i++){
for (int j=0; j<2010; j++) dp2 [i][j]=1e18;
}
for (int i=0; i<n; i++) cin >> l [i];
pref [0]=l [0];
for (int i=1; i<n; i++) pref [i]=pref [i-1]+l [i];
long long int ans=0;
for (long long int b=49; b>=0; b--){
for (int i=0; i<n; i++){
if ((((ans >> b) | ((pref [i])>>b)) == (ans >> b))) dp2 [b][i]=1;
for (int j=i-1; j>=0; j--){
if ((((ans >> b) | ((pref [i]-pref [j])>>b)) == (ans >> b))) dp2 [b][i]=min (dp2 [b][i], dp2 [b][j]+1);
}
}
if (dp2 [b][n-1]>grb) ans|=((long long)1<<b);
}
cout << ans << endl;
return 0;
}
for (int i=0; i<n; i++) cin >> l [i];
pref [0]=l [0];
for (int i=1; i<n; i++) pref [i]=pref [i-1]+l [i];
long long int ans=0;
for (long long int b=49; b>=0; b--){
for (int i=0; i<n; i++){
for (int j=0; j<n+1; j++){
if ((((ans >> b) | ((pref [i])>>b)) == (ans >> b))) dp [b][i][1]=1;
for (int k=i-1; k>=0; k--){
if ((((ans >> b) | ((pref [i]-pref [k])>>b)) == (ans >> b))) dp [b][i][j]=max (dp [b][i][j], dp [b][k][j-1]);
}
}
}
int da=0;
for (int i=gra; i<=grb; i++) if (dp [b][n-1][i]) da=1;
if (!da) ans|=((long long)1<<b);
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
1108 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
1 ms |
976 KB |
Output is correct |
15 |
Correct |
1 ms |
852 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
1 ms |
1748 KB |
Output is correct |
21 |
Correct |
1 ms |
2004 KB |
Output is correct |
22 |
Correct |
1 ms |
2004 KB |
Output is correct |
23 |
Correct |
2 ms |
2004 KB |
Output is correct |
24 |
Correct |
1 ms |
2004 KB |
Output is correct |
25 |
Correct |
1 ms |
2004 KB |
Output is correct |
26 |
Correct |
1 ms |
2004 KB |
Output is correct |
27 |
Correct |
1 ms |
1108 KB |
Output is correct |
28 |
Correct |
1 ms |
980 KB |
Output is correct |
29 |
Correct |
1 ms |
980 KB |
Output is correct |
30 |
Correct |
1 ms |
980 KB |
Output is correct |
31 |
Correct |
1 ms |
1108 KB |
Output is correct |
32 |
Correct |
1 ms |
980 KB |
Output is correct |
33 |
Correct |
1 ms |
980 KB |
Output is correct |
34 |
Correct |
1 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
980 KB |
Output is correct |
36 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
1104 KB |
Output is correct |
14 |
Correct |
1 ms |
852 KB |
Output is correct |
15 |
Correct |
1 ms |
852 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
1360 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
1 ms |
1748 KB |
Output is correct |
21 |
Correct |
1 ms |
2004 KB |
Output is correct |
22 |
Correct |
1 ms |
2004 KB |
Output is correct |
23 |
Correct |
1 ms |
2004 KB |
Output is correct |
24 |
Correct |
1 ms |
2004 KB |
Output is correct |
25 |
Correct |
2 ms |
2004 KB |
Output is correct |
26 |
Correct |
2 ms |
2004 KB |
Output is correct |
27 |
Correct |
1 ms |
980 KB |
Output is correct |
28 |
Correct |
1 ms |
980 KB |
Output is correct |
29 |
Correct |
1 ms |
1108 KB |
Output is correct |
30 |
Correct |
1 ms |
980 KB |
Output is correct |
31 |
Correct |
1 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
980 KB |
Output is correct |
33 |
Correct |
1 ms |
1108 KB |
Output is correct |
34 |
Correct |
1 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
1108 KB |
Output is correct |
36 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
1232 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
1104 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
1 ms |
980 KB |
Output is correct |
15 |
Correct |
1 ms |
980 KB |
Output is correct |
16 |
Correct |
1 ms |
980 KB |
Output is correct |
17 |
Correct |
1 ms |
980 KB |
Output is correct |
18 |
Correct |
1 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
1156 KB |
Output is correct |
20 |
Correct |
1 ms |
980 KB |
Output is correct |
21 |
Correct |
1 ms |
980 KB |
Output is correct |
22 |
Correct |
1 ms |
980 KB |
Output is correct |
23 |
Correct |
1 ms |
980 KB |
Output is correct |
24 |
Correct |
1 ms |
980 KB |
Output is correct |
25 |
Correct |
1 ms |
980 KB |
Output is correct |
26 |
Correct |
1 ms |
980 KB |
Output is correct |
27 |
Correct |
1 ms |
980 KB |
Output is correct |
28 |
Correct |
1 ms |
1108 KB |
Output is correct |
29 |
Correct |
2 ms |
1108 KB |
Output is correct |
30 |
Correct |
1 ms |
980 KB |
Output is correct |
31 |
Correct |
1 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1108 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
1108 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
980 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
1136 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
1 ms |
880 KB |
Output is correct |
15 |
Correct |
1 ms |
852 KB |
Output is correct |
16 |
Correct |
1 ms |
852 KB |
Output is correct |
17 |
Correct |
1 ms |
852 KB |
Output is correct |
18 |
Correct |
1 ms |
1236 KB |
Output is correct |
19 |
Correct |
1 ms |
1620 KB |
Output is correct |
20 |
Correct |
2 ms |
1748 KB |
Output is correct |
21 |
Correct |
1 ms |
2004 KB |
Output is correct |
22 |
Correct |
2 ms |
2004 KB |
Output is correct |
23 |
Correct |
1 ms |
2004 KB |
Output is correct |
24 |
Correct |
2 ms |
2004 KB |
Output is correct |
25 |
Correct |
2 ms |
2004 KB |
Output is correct |
26 |
Correct |
1 ms |
2004 KB |
Output is correct |
27 |
Correct |
1 ms |
980 KB |
Output is correct |
28 |
Correct |
1 ms |
980 KB |
Output is correct |
29 |
Correct |
1 ms |
980 KB |
Output is correct |
30 |
Correct |
1 ms |
980 KB |
Output is correct |
31 |
Correct |
1 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
1108 KB |
Output is correct |
33 |
Correct |
1 ms |
980 KB |
Output is correct |
34 |
Correct |
1 ms |
1108 KB |
Output is correct |
35 |
Correct |
1 ms |
980 KB |
Output is correct |
36 |
Correct |
1 ms |
980 KB |
Output is correct |
37 |
Correct |
1 ms |
980 KB |
Output is correct |
38 |
Correct |
1 ms |
980 KB |
Output is correct |
39 |
Correct |
1 ms |
980 KB |
Output is correct |
40 |
Correct |
1 ms |
980 KB |
Output is correct |
41 |
Correct |
1 ms |
980 KB |
Output is correct |
42 |
Correct |
1 ms |
980 KB |
Output is correct |
43 |
Correct |
1 ms |
980 KB |
Output is correct |
44 |
Correct |
1 ms |
980 KB |
Output is correct |
45 |
Correct |
1 ms |
980 KB |
Output is correct |
46 |
Correct |
1 ms |
1108 KB |
Output is correct |
47 |
Correct |
1 ms |
980 KB |
Output is correct |
48 |
Correct |
1 ms |
980 KB |
Output is correct |
49 |
Correct |
1 ms |
980 KB |
Output is correct |
50 |
Correct |
1 ms |
980 KB |
Output is correct |
51 |
Correct |
1 ms |
980 KB |
Output is correct |
52 |
Correct |
1 ms |
980 KB |
Output is correct |
53 |
Correct |
1 ms |
1108 KB |
Output is correct |
54 |
Correct |
1 ms |
980 KB |
Output is correct |
55 |
Correct |
2 ms |
980 KB |
Output is correct |
56 |
Correct |
1 ms |
980 KB |
Output is correct |
57 |
Correct |
1 ms |
980 KB |
Output is correct |
58 |
Correct |
1 ms |
1108 KB |
Output is correct |
59 |
Correct |
1 ms |
980 KB |
Output is correct |
60 |
Correct |
1 ms |
980 KB |
Output is correct |
61 |
Correct |
1 ms |
980 KB |
Output is correct |
62 |
Correct |
1 ms |
980 KB |
Output is correct |
63 |
Correct |
1 ms |
980 KB |
Output is correct |
64 |
Correct |
47 ms |
7764 KB |
Output is correct |
65 |
Correct |
7 ms |
4308 KB |
Output is correct |
66 |
Correct |
12 ms |
5588 KB |
Output is correct |
67 |
Correct |
19 ms |
6612 KB |
Output is correct |
68 |
Correct |
31 ms |
7764 KB |
Output is correct |
69 |
Correct |
38 ms |
8296 KB |
Output is correct |
70 |
Correct |
35 ms |
6476 KB |
Output is correct |
71 |
Correct |
37 ms |
5836 KB |
Output is correct |
72 |
Correct |
44 ms |
8588 KB |
Output is correct |
73 |
Correct |
41 ms |
8652 KB |
Output is correct |
74 |
Correct |
47 ms |
8780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
1 ms |
980 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
1 ms |
1108 KB |
Output is correct |
11 |
Correct |
1 ms |
980 KB |
Output is correct |
12 |
Correct |
1 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
1 ms |
980 KB |
Output is correct |
15 |
Correct |
1 ms |
980 KB |
Output is correct |
16 |
Correct |
1 ms |
980 KB |
Output is correct |
17 |
Correct |
1 ms |
980 KB |
Output is correct |
18 |
Correct |
1 ms |
980 KB |
Output is correct |
19 |
Correct |
1 ms |
980 KB |
Output is correct |
20 |
Correct |
1 ms |
980 KB |
Output is correct |
21 |
Correct |
1 ms |
1108 KB |
Output is correct |
22 |
Correct |
1 ms |
980 KB |
Output is correct |
23 |
Correct |
1 ms |
980 KB |
Output is correct |
24 |
Correct |
1 ms |
980 KB |
Output is correct |
25 |
Correct |
1 ms |
980 KB |
Output is correct |
26 |
Correct |
1 ms |
980 KB |
Output is correct |
27 |
Correct |
1 ms |
980 KB |
Output is correct |
28 |
Correct |
1 ms |
980 KB |
Output is correct |
29 |
Correct |
1 ms |
980 KB |
Output is correct |
30 |
Correct |
1 ms |
980 KB |
Output is correct |
31 |
Correct |
1 ms |
980 KB |
Output is correct |
32 |
Correct |
1 ms |
1108 KB |
Output is correct |
33 |
Correct |
1 ms |
980 KB |
Output is correct |
34 |
Correct |
1 ms |
980 KB |
Output is correct |
35 |
Correct |
1 ms |
980 KB |
Output is correct |
36 |
Correct |
1 ms |
1024 KB |
Output is correct |
37 |
Correct |
2 ms |
980 KB |
Output is correct |
38 |
Correct |
1 ms |
980 KB |
Output is correct |
39 |
Correct |
1 ms |
980 KB |
Output is correct |
40 |
Correct |
1 ms |
980 KB |
Output is correct |
41 |
Correct |
1 ms |
1108 KB |
Output is correct |
42 |
Correct |
1 ms |
1108 KB |
Output is correct |
43 |
Correct |
1 ms |
980 KB |
Output is correct |
44 |
Correct |
1 ms |
980 KB |
Output is correct |
45 |
Correct |
1 ms |
980 KB |
Output is correct |
46 |
Correct |
1 ms |
980 KB |
Output is correct |
47 |
Correct |
1 ms |
980 KB |
Output is correct |
48 |
Correct |
1 ms |
1108 KB |
Output is correct |
49 |
Correct |
1 ms |
1108 KB |
Output is correct |
50 |
Correct |
1 ms |
980 KB |
Output is correct |
51 |
Correct |
1 ms |
980 KB |
Output is correct |
52 |
Correct |
8 ms |
1108 KB |
Output is correct |
53 |
Correct |
12 ms |
1108 KB |
Output is correct |
54 |
Correct |
22 ms |
1108 KB |
Output is correct |
55 |
Correct |
20 ms |
1116 KB |
Output is correct |
56 |
Correct |
76 ms |
1108 KB |
Output is correct |
57 |
Correct |
77 ms |
1108 KB |
Output is correct |
58 |
Correct |
74 ms |
1108 KB |
Output is correct |
59 |
Correct |
74 ms |
1108 KB |
Output is correct |
60 |
Correct |
78 ms |
1108 KB |
Output is correct |
61 |
Correct |
1 ms |
980 KB |
Output is correct |
62 |
Correct |
12 ms |
1108 KB |
Output is correct |
63 |
Correct |
26 ms |
1112 KB |
Output is correct |
64 |
Correct |
20 ms |
1108 KB |
Output is correct |
65 |
Correct |
38 ms |
1108 KB |
Output is correct |
66 |
Correct |
57 ms |
1108 KB |
Output is correct |
67 |
Correct |
78 ms |
1108 KB |
Output is correct |
68 |
Correct |
83 ms |
1108 KB |
Output is correct |
69 |
Correct |
76 ms |
1108 KB |
Output is correct |