#include <bits/stdc++.h>
#define ll long long
#define N 2005
using namespace std;
bool dp[N][N];
int dp2[N];
int n,A,B;
ll ans,arr[N],sum=0;
void init()
{
cin >> n >> A >> B;
for(int i=1;i<=n;++i){
cin >> arr[i];
sum+=arr[i];
}
}
void solve()
{
int maxn=log2(sum)+1;
for(int i=maxn;i>=0;--i){
ll res=( ans|( ((ll)1<<i)-(ll)1 ) );
memset(dp,0,sizeof(dp));
dp[0][0]=true;
for(int j=1;j<=n;++j){ //第J個數
for(int k=1;k<=min(j,B);++k){ //分段數
ll SUM=0;
for(int t=j-1;t>=k-1;--t){ //分割點
SUM+=arr[t+1];
if(dp[t][k-1] && ((SUM|res)==res) ){
dp[j][k]=true;
break;
}
}
}
}
bool flag=false;
for(int j=A;j<=B;++j){
if(dp[n][j]){
flag=true;
break;
}
}
if(!flag)
ans|=((ll)1<<i);
}
}
void solve2()
{
int maxn=log2(sum)+1;
for(int i=maxn;i>=0;--i){
ll res=( ans|( ((ll)1<<i)-(ll)1 ) );
memset(dp2,0x7f,sizeof(dp2));
dp2[0]=0;
for(int j=1;j<=n;++j){
ll SUM=0;
for(int k=j-1;k>=0;--k){
SUM+=arr[k+1];
if((SUM|res)==res)
dp2[j]=min(dp2[j],dp2[k]+1);
}
}
if(dp2[n]>B)
ans|=((ll)1<<i);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
init();
// if(A==1)
// solve2();
// else
solve();
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4216 KB |
Output is correct |
2 |
Correct |
8 ms |
4216 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
4344 KB |
Output is correct |
5 |
Correct |
8 ms |
4216 KB |
Output is correct |
6 |
Correct |
8 ms |
4216 KB |
Output is correct |
7 |
Correct |
8 ms |
4216 KB |
Output is correct |
8 |
Correct |
8 ms |
4216 KB |
Output is correct |
9 |
Correct |
9 ms |
4348 KB |
Output is correct |
10 |
Correct |
8 ms |
4216 KB |
Output is correct |
11 |
Correct |
8 ms |
4344 KB |
Output is correct |
12 |
Correct |
8 ms |
4216 KB |
Output is correct |
13 |
Correct |
8 ms |
4216 KB |
Output is correct |
14 |
Correct |
8 ms |
4216 KB |
Output is correct |
15 |
Correct |
7 ms |
4344 KB |
Output is correct |
16 |
Correct |
7 ms |
4216 KB |
Output is correct |
17 |
Correct |
8 ms |
4216 KB |
Output is correct |
18 |
Correct |
14 ms |
4216 KB |
Output is correct |
19 |
Correct |
8 ms |
4216 KB |
Output is correct |
20 |
Correct |
8 ms |
4216 KB |
Output is correct |
21 |
Correct |
8 ms |
4264 KB |
Output is correct |
22 |
Correct |
8 ms |
4216 KB |
Output is correct |
23 |
Correct |
8 ms |
4216 KB |
Output is correct |
24 |
Correct |
8 ms |
4216 KB |
Output is correct |
25 |
Correct |
8 ms |
4216 KB |
Output is correct |
26 |
Correct |
8 ms |
4216 KB |
Output is correct |
27 |
Correct |
11 ms |
4216 KB |
Output is correct |
28 |
Correct |
12 ms |
4216 KB |
Output is correct |
29 |
Correct |
11 ms |
4216 KB |
Output is correct |
30 |
Correct |
11 ms |
4216 KB |
Output is correct |
31 |
Correct |
16 ms |
4216 KB |
Output is correct |
32 |
Correct |
11 ms |
4216 KB |
Output is correct |
33 |
Correct |
12 ms |
4216 KB |
Output is correct |
34 |
Correct |
15 ms |
4348 KB |
Output is correct |
35 |
Correct |
13 ms |
4216 KB |
Output is correct |
36 |
Correct |
11 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4220 KB |
Output is correct |
2 |
Correct |
8 ms |
4216 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
4216 KB |
Output is correct |
5 |
Correct |
8 ms |
4344 KB |
Output is correct |
6 |
Correct |
8 ms |
4216 KB |
Output is correct |
7 |
Correct |
8 ms |
4216 KB |
Output is correct |
8 |
Correct |
8 ms |
4344 KB |
Output is correct |
9 |
Correct |
8 ms |
4344 KB |
Output is correct |
10 |
Correct |
9 ms |
4472 KB |
Output is correct |
11 |
Correct |
8 ms |
4216 KB |
Output is correct |
12 |
Correct |
8 ms |
4216 KB |
Output is correct |
13 |
Correct |
8 ms |
4216 KB |
Output is correct |
14 |
Correct |
7 ms |
4216 KB |
Output is correct |
15 |
Correct |
8 ms |
4216 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
8 ms |
4216 KB |
Output is correct |
18 |
Correct |
8 ms |
4344 KB |
Output is correct |
19 |
Correct |
8 ms |
4216 KB |
Output is correct |
20 |
Correct |
8 ms |
4344 KB |
Output is correct |
21 |
Correct |
8 ms |
4220 KB |
Output is correct |
22 |
Correct |
8 ms |
4220 KB |
Output is correct |
23 |
Correct |
8 ms |
4216 KB |
Output is correct |
24 |
Correct |
8 ms |
4220 KB |
Output is correct |
25 |
Correct |
8 ms |
4216 KB |
Output is correct |
26 |
Correct |
8 ms |
4216 KB |
Output is correct |
27 |
Correct |
8 ms |
4216 KB |
Output is correct |
28 |
Correct |
10 ms |
4216 KB |
Output is correct |
29 |
Correct |
8 ms |
4216 KB |
Output is correct |
30 |
Correct |
8 ms |
4216 KB |
Output is correct |
31 |
Correct |
9 ms |
4216 KB |
Output is correct |
32 |
Correct |
8 ms |
4216 KB |
Output is correct |
33 |
Correct |
8 ms |
4216 KB |
Output is correct |
34 |
Correct |
8 ms |
4220 KB |
Output is correct |
35 |
Correct |
8 ms |
4216 KB |
Output is correct |
36 |
Correct |
8 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4216 KB |
Output is correct |
2 |
Correct |
7 ms |
4344 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
4216 KB |
Output is correct |
5 |
Correct |
8 ms |
4216 KB |
Output is correct |
6 |
Correct |
8 ms |
4344 KB |
Output is correct |
7 |
Correct |
8 ms |
4216 KB |
Output is correct |
8 |
Correct |
8 ms |
4344 KB |
Output is correct |
9 |
Correct |
8 ms |
4216 KB |
Output is correct |
10 |
Correct |
8 ms |
4216 KB |
Output is correct |
11 |
Correct |
9 ms |
4344 KB |
Output is correct |
12 |
Correct |
8 ms |
4344 KB |
Output is correct |
13 |
Correct |
8 ms |
4344 KB |
Output is correct |
14 |
Correct |
8 ms |
4216 KB |
Output is correct |
15 |
Correct |
8 ms |
4344 KB |
Output is correct |
16 |
Correct |
8 ms |
4216 KB |
Output is correct |
17 |
Correct |
8 ms |
4216 KB |
Output is correct |
18 |
Correct |
9 ms |
4216 KB |
Output is correct |
19 |
Correct |
8 ms |
4216 KB |
Output is correct |
20 |
Correct |
8 ms |
4344 KB |
Output is correct |
21 |
Correct |
8 ms |
4216 KB |
Output is correct |
22 |
Correct |
8 ms |
4212 KB |
Output is correct |
23 |
Correct |
9 ms |
4216 KB |
Output is correct |
24 |
Correct |
9 ms |
4216 KB |
Output is correct |
25 |
Correct |
9 ms |
4216 KB |
Output is correct |
26 |
Correct |
9 ms |
4216 KB |
Output is correct |
27 |
Correct |
11 ms |
4344 KB |
Output is correct |
28 |
Correct |
11 ms |
4216 KB |
Output is correct |
29 |
Correct |
11 ms |
4344 KB |
Output is correct |
30 |
Correct |
8 ms |
4216 KB |
Output is correct |
31 |
Correct |
15 ms |
4344 KB |
Output is correct |
32 |
Correct |
11 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
4216 KB |
Output is correct |
2 |
Correct |
8 ms |
4344 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
7 ms |
4216 KB |
Output is correct |
5 |
Correct |
8 ms |
4216 KB |
Output is correct |
6 |
Correct |
8 ms |
4216 KB |
Output is correct |
7 |
Correct |
8 ms |
4216 KB |
Output is correct |
8 |
Correct |
8 ms |
4216 KB |
Output is correct |
9 |
Correct |
8 ms |
4216 KB |
Output is correct |
10 |
Correct |
8 ms |
4216 KB |
Output is correct |
11 |
Correct |
8 ms |
4216 KB |
Output is correct |
12 |
Correct |
8 ms |
4216 KB |
Output is correct |
13 |
Correct |
9 ms |
4216 KB |
Output is correct |
14 |
Correct |
8 ms |
4216 KB |
Output is correct |
15 |
Correct |
8 ms |
4344 KB |
Output is correct |
16 |
Correct |
7 ms |
4216 KB |
Output is correct |
17 |
Correct |
8 ms |
4216 KB |
Output is correct |
18 |
Correct |
8 ms |
4216 KB |
Output is correct |
19 |
Correct |
8 ms |
4216 KB |
Output is correct |
20 |
Correct |
8 ms |
4216 KB |
Output is correct |
21 |
Correct |
8 ms |
4220 KB |
Output is correct |
22 |
Correct |
8 ms |
4216 KB |
Output is correct |
23 |
Correct |
8 ms |
4216 KB |
Output is correct |
24 |
Correct |
8 ms |
4216 KB |
Output is correct |
25 |
Correct |
8 ms |
4216 KB |
Output is correct |
26 |
Correct |
8 ms |
4344 KB |
Output is correct |
27 |
Correct |
11 ms |
4216 KB |
Output is correct |
28 |
Correct |
11 ms |
4216 KB |
Output is correct |
29 |
Correct |
12 ms |
4216 KB |
Output is correct |
30 |
Correct |
11 ms |
4216 KB |
Output is correct |
31 |
Correct |
11 ms |
4216 KB |
Output is correct |
32 |
Correct |
12 ms |
4344 KB |
Output is correct |
33 |
Correct |
11 ms |
4344 KB |
Output is correct |
34 |
Correct |
11 ms |
4344 KB |
Output is correct |
35 |
Correct |
11 ms |
4216 KB |
Output is correct |
36 |
Correct |
11 ms |
4216 KB |
Output is correct |
37 |
Correct |
8 ms |
4216 KB |
Output is correct |
38 |
Correct |
8 ms |
4216 KB |
Output is correct |
39 |
Correct |
8 ms |
4216 KB |
Output is correct |
40 |
Correct |
8 ms |
4216 KB |
Output is correct |
41 |
Correct |
10 ms |
4216 KB |
Output is correct |
42 |
Correct |
8 ms |
4344 KB |
Output is correct |
43 |
Correct |
9 ms |
4216 KB |
Output is correct |
44 |
Correct |
8 ms |
4216 KB |
Output is correct |
45 |
Correct |
8 ms |
4344 KB |
Output is correct |
46 |
Correct |
9 ms |
4216 KB |
Output is correct |
47 |
Correct |
8 ms |
4344 KB |
Output is correct |
48 |
Correct |
8 ms |
4216 KB |
Output is correct |
49 |
Correct |
10 ms |
4344 KB |
Output is correct |
50 |
Correct |
10 ms |
4216 KB |
Output is correct |
51 |
Correct |
11 ms |
4216 KB |
Output is correct |
52 |
Correct |
11 ms |
4344 KB |
Output is correct |
53 |
Correct |
8 ms |
4216 KB |
Output is correct |
54 |
Correct |
10 ms |
4216 KB |
Output is correct |
55 |
Correct |
11 ms |
4344 KB |
Output is correct |
56 |
Correct |
13 ms |
4216 KB |
Output is correct |
57 |
Correct |
14 ms |
4216 KB |
Output is correct |
58 |
Correct |
18 ms |
4216 KB |
Output is correct |
59 |
Correct |
20 ms |
4344 KB |
Output is correct |
60 |
Correct |
27 ms |
4344 KB |
Output is correct |
61 |
Correct |
12 ms |
4344 KB |
Output is correct |
62 |
Correct |
21 ms |
4220 KB |
Output is correct |
63 |
Correct |
20 ms |
4216 KB |
Output is correct |
64 |
Correct |
8 ms |
4216 KB |
Output is correct |
65 |
Correct |
13 ms |
4344 KB |
Output is correct |
66 |
Correct |
13 ms |
4216 KB |
Output is correct |
67 |
Correct |
16 ms |
4216 KB |
Output is correct |
68 |
Correct |
18 ms |
4216 KB |
Output is correct |
69 |
Correct |
20 ms |
4216 KB |
Output is correct |
70 |
Correct |
21 ms |
4344 KB |
Output is correct |
71 |
Correct |
12 ms |
4216 KB |
Output is correct |
72 |
Correct |
21 ms |
4216 KB |
Output is correct |
73 |
Correct |
20 ms |
4220 KB |
Output is correct |
74 |
Correct |
19 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4216 KB |
Output is correct |
2 |
Correct |
8 ms |
4216 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
4216 KB |
Output is correct |
5 |
Correct |
8 ms |
4344 KB |
Output is correct |
6 |
Correct |
8 ms |
4216 KB |
Output is correct |
7 |
Correct |
8 ms |
4344 KB |
Output is correct |
8 |
Correct |
8 ms |
4216 KB |
Output is correct |
9 |
Correct |
8 ms |
4216 KB |
Output is correct |
10 |
Correct |
8 ms |
4216 KB |
Output is correct |
11 |
Correct |
8 ms |
4216 KB |
Output is correct |
12 |
Correct |
8 ms |
4216 KB |
Output is correct |
13 |
Correct |
8 ms |
4216 KB |
Output is correct |
14 |
Correct |
11 ms |
4216 KB |
Output is correct |
15 |
Correct |
12 ms |
4216 KB |
Output is correct |
16 |
Correct |
11 ms |
4216 KB |
Output is correct |
17 |
Correct |
11 ms |
4216 KB |
Output is correct |
18 |
Correct |
12 ms |
4216 KB |
Output is correct |
19 |
Correct |
11 ms |
4344 KB |
Output is correct |
20 |
Correct |
11 ms |
4216 KB |
Output is correct |
21 |
Correct |
11 ms |
4344 KB |
Output is correct |
22 |
Correct |
11 ms |
4344 KB |
Output is correct |
23 |
Correct |
14 ms |
4216 KB |
Output is correct |
24 |
Correct |
8 ms |
4216 KB |
Output is correct |
25 |
Correct |
8 ms |
4344 KB |
Output is correct |
26 |
Correct |
9 ms |
4216 KB |
Output is correct |
27 |
Correct |
8 ms |
4216 KB |
Output is correct |
28 |
Correct |
8 ms |
4216 KB |
Output is correct |
29 |
Correct |
8 ms |
4216 KB |
Output is correct |
30 |
Correct |
8 ms |
4216 KB |
Output is correct |
31 |
Correct |
8 ms |
4216 KB |
Output is correct |
32 |
Correct |
10 ms |
4216 KB |
Output is correct |
33 |
Correct |
8 ms |
4216 KB |
Output is correct |
34 |
Correct |
8 ms |
4344 KB |
Output is correct |
35 |
Correct |
9 ms |
4344 KB |
Output is correct |
36 |
Correct |
9 ms |
4216 KB |
Output is correct |
37 |
Correct |
10 ms |
4216 KB |
Output is correct |
38 |
Correct |
10 ms |
4344 KB |
Output is correct |
39 |
Correct |
10 ms |
4216 KB |
Output is correct |
40 |
Correct |
9 ms |
4216 KB |
Output is correct |
41 |
Correct |
10 ms |
4216 KB |
Output is correct |
42 |
Correct |
11 ms |
4216 KB |
Output is correct |
43 |
Correct |
15 ms |
4216 KB |
Output is correct |
44 |
Correct |
15 ms |
4216 KB |
Output is correct |
45 |
Correct |
19 ms |
4212 KB |
Output is correct |
46 |
Correct |
20 ms |
4216 KB |
Output is correct |
47 |
Correct |
21 ms |
4216 KB |
Output is correct |
48 |
Correct |
12 ms |
4216 KB |
Output is correct |
49 |
Correct |
20 ms |
4216 KB |
Output is correct |
50 |
Correct |
21 ms |
4216 KB |
Output is correct |
51 |
Correct |
16 ms |
4216 KB |
Output is correct |
52 |
Correct |
687 ms |
4344 KB |
Output is correct |
53 |
Execution timed out |
1092 ms |
4216 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |