#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
template<class T> inline bool chmin(T &a, T b){
if(a>b){a=b;return true;}
return false;
}
template<class T> inline bool chmax(T &a, T b){
if(a<b){a=b;return true;}
return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;
int N,A,B;
int Y[2005];
bool dp[2005][2005];
int dp2[2005];
void solve1(){
int anti=0;
rev(i,40){
anti+=1ll<<i;
memset(dp,0,sizeof(dp));
dp[0][0]=true;
rep(j,N){
rep(k,B){
if(!dp[j][k])continue;
int sum=0;
for(int l=j;l<N;l++){
sum+=Y[l];
if((sum&anti)==0)dp[l+1][k+1]=true;
}
}
}
bool flag=false;
for(int j=A;j<=B;j++)flag|=dp[N][j];
if(!flag)anti^=1ll<<i;
}
cout<<(anti^((1ll<<40)-1))<<endl;
}
void solve2(){
int anti=0;
rev(i,40){
anti+=1ll<<i;
fill(dp2,dp2+N+1,inf);
dp2[0]=0;
rep(j,N){
int sum=0;
for(int k=j;k<N;k++){
sum+=Y[k];
if((anti&sum)==0)chmin(dp2[k+1],dp2[j]+1);
}
}
if(dp2[N]>B)anti^=1ll<<i;
}
cout<<(anti^((1ll<<40)-1))<<endl;
}
signed main(){
cin>>N>>A>>B;
rep(i,N)cin>>Y[i];
int ans=0,anti=0;
if(N<=100)solve1();
else solve2();
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:68:6: warning: unused variable 'ans' [-Wunused-variable]
int ans=0,anti=0;
^~~
sculpture.cpp:68:12: warning: unused variable 'anti' [-Wunused-variable]
int ans=0,anti=0;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4224 KB |
Output is correct |
2 |
Correct |
7 ms |
4312 KB |
Output is correct |
3 |
Correct |
7 ms |
4224 KB |
Output is correct |
4 |
Correct |
7 ms |
4224 KB |
Output is correct |
5 |
Correct |
7 ms |
4224 KB |
Output is correct |
6 |
Correct |
7 ms |
4224 KB |
Output is correct |
7 |
Correct |
8 ms |
4224 KB |
Output is correct |
8 |
Correct |
7 ms |
4224 KB |
Output is correct |
9 |
Correct |
8 ms |
4308 KB |
Output is correct |
10 |
Correct |
7 ms |
4224 KB |
Output is correct |
11 |
Correct |
7 ms |
4224 KB |
Output is correct |
12 |
Correct |
7 ms |
4224 KB |
Output is correct |
13 |
Correct |
7 ms |
4224 KB |
Output is correct |
14 |
Correct |
7 ms |
4224 KB |
Output is correct |
15 |
Correct |
7 ms |
4224 KB |
Output is correct |
16 |
Correct |
7 ms |
4224 KB |
Output is correct |
17 |
Correct |
7 ms |
4224 KB |
Output is correct |
18 |
Correct |
7 ms |
4224 KB |
Output is correct |
19 |
Correct |
7 ms |
4224 KB |
Output is correct |
20 |
Correct |
7 ms |
4224 KB |
Output is correct |
21 |
Correct |
7 ms |
4224 KB |
Output is correct |
22 |
Correct |
7 ms |
4224 KB |
Output is correct |
23 |
Correct |
7 ms |
4316 KB |
Output is correct |
24 |
Correct |
7 ms |
4224 KB |
Output is correct |
25 |
Correct |
7 ms |
4224 KB |
Output is correct |
26 |
Correct |
7 ms |
4224 KB |
Output is correct |
27 |
Correct |
7 ms |
4312 KB |
Output is correct |
28 |
Correct |
7 ms |
4224 KB |
Output is correct |
29 |
Correct |
7 ms |
4224 KB |
Output is correct |
30 |
Correct |
7 ms |
4224 KB |
Output is correct |
31 |
Correct |
8 ms |
4224 KB |
Output is correct |
32 |
Correct |
8 ms |
4224 KB |
Output is correct |
33 |
Correct |
7 ms |
4224 KB |
Output is correct |
34 |
Correct |
7 ms |
4224 KB |
Output is correct |
35 |
Correct |
9 ms |
4312 KB |
Output is correct |
36 |
Correct |
7 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4224 KB |
Output is correct |
2 |
Correct |
9 ms |
4224 KB |
Output is correct |
3 |
Correct |
7 ms |
4224 KB |
Output is correct |
4 |
Correct |
7 ms |
4224 KB |
Output is correct |
5 |
Correct |
7 ms |
4224 KB |
Output is correct |
6 |
Correct |
7 ms |
4224 KB |
Output is correct |
7 |
Correct |
7 ms |
4224 KB |
Output is correct |
8 |
Correct |
8 ms |
4224 KB |
Output is correct |
9 |
Correct |
7 ms |
4224 KB |
Output is correct |
10 |
Correct |
8 ms |
4224 KB |
Output is correct |
11 |
Correct |
8 ms |
4224 KB |
Output is correct |
12 |
Correct |
7 ms |
4224 KB |
Output is correct |
13 |
Correct |
8 ms |
4224 KB |
Output is correct |
14 |
Correct |
8 ms |
4224 KB |
Output is correct |
15 |
Correct |
7 ms |
4224 KB |
Output is correct |
16 |
Correct |
7 ms |
4224 KB |
Output is correct |
17 |
Correct |
7 ms |
4224 KB |
Output is correct |
18 |
Correct |
7 ms |
4224 KB |
Output is correct |
19 |
Correct |
7 ms |
4224 KB |
Output is correct |
20 |
Correct |
8 ms |
4224 KB |
Output is correct |
21 |
Correct |
7 ms |
4224 KB |
Output is correct |
22 |
Correct |
9 ms |
4316 KB |
Output is correct |
23 |
Correct |
10 ms |
4224 KB |
Output is correct |
24 |
Correct |
7 ms |
4224 KB |
Output is correct |
25 |
Correct |
7 ms |
4224 KB |
Output is correct |
26 |
Correct |
7 ms |
4224 KB |
Output is correct |
27 |
Correct |
16 ms |
4224 KB |
Output is correct |
28 |
Correct |
8 ms |
4224 KB |
Output is correct |
29 |
Correct |
12 ms |
4224 KB |
Output is correct |
30 |
Correct |
13 ms |
4224 KB |
Output is correct |
31 |
Correct |
8 ms |
4224 KB |
Output is correct |
32 |
Correct |
8 ms |
4224 KB |
Output is correct |
33 |
Correct |
12 ms |
4224 KB |
Output is correct |
34 |
Correct |
8 ms |
4224 KB |
Output is correct |
35 |
Correct |
13 ms |
4224 KB |
Output is correct |
36 |
Correct |
8 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4224 KB |
Output is correct |
2 |
Correct |
7 ms |
4224 KB |
Output is correct |
3 |
Correct |
7 ms |
4224 KB |
Output is correct |
4 |
Correct |
7 ms |
4224 KB |
Output is correct |
5 |
Correct |
7 ms |
4224 KB |
Output is correct |
6 |
Correct |
7 ms |
4224 KB |
Output is correct |
7 |
Correct |
7 ms |
4224 KB |
Output is correct |
8 |
Correct |
8 ms |
4224 KB |
Output is correct |
9 |
Correct |
7 ms |
4224 KB |
Output is correct |
10 |
Correct |
8 ms |
4224 KB |
Output is correct |
11 |
Correct |
7 ms |
4224 KB |
Output is correct |
12 |
Correct |
7 ms |
4224 KB |
Output is correct |
13 |
Correct |
8 ms |
4224 KB |
Output is correct |
14 |
Correct |
8 ms |
4224 KB |
Output is correct |
15 |
Correct |
9 ms |
4352 KB |
Output is correct |
16 |
Correct |
7 ms |
4224 KB |
Output is correct |
17 |
Correct |
9 ms |
4224 KB |
Output is correct |
18 |
Correct |
7 ms |
4224 KB |
Output is correct |
19 |
Correct |
7 ms |
4224 KB |
Output is correct |
20 |
Correct |
8 ms |
4224 KB |
Output is correct |
21 |
Correct |
8 ms |
4224 KB |
Output is correct |
22 |
Correct |
8 ms |
4224 KB |
Output is correct |
23 |
Correct |
7 ms |
4224 KB |
Output is correct |
24 |
Correct |
8 ms |
4224 KB |
Output is correct |
25 |
Correct |
8 ms |
4224 KB |
Output is correct |
26 |
Correct |
9 ms |
4224 KB |
Output is correct |
27 |
Correct |
10 ms |
4224 KB |
Output is correct |
28 |
Correct |
13 ms |
4224 KB |
Output is correct |
29 |
Correct |
13 ms |
4224 KB |
Output is correct |
30 |
Correct |
9 ms |
4224 KB |
Output is correct |
31 |
Correct |
11 ms |
4224 KB |
Output is correct |
32 |
Correct |
13 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4224 KB |
Output is correct |
2 |
Correct |
8 ms |
4224 KB |
Output is correct |
3 |
Correct |
7 ms |
4224 KB |
Output is correct |
4 |
Correct |
8 ms |
4224 KB |
Output is correct |
5 |
Correct |
7 ms |
4224 KB |
Output is correct |
6 |
Correct |
8 ms |
4224 KB |
Output is correct |
7 |
Correct |
7 ms |
4224 KB |
Output is correct |
8 |
Correct |
8 ms |
4308 KB |
Output is correct |
9 |
Correct |
7 ms |
4224 KB |
Output is correct |
10 |
Correct |
7 ms |
4224 KB |
Output is correct |
11 |
Correct |
7 ms |
4224 KB |
Output is correct |
12 |
Correct |
7 ms |
4224 KB |
Output is correct |
13 |
Correct |
7 ms |
4224 KB |
Output is correct |
14 |
Correct |
7 ms |
4224 KB |
Output is correct |
15 |
Correct |
7 ms |
4224 KB |
Output is correct |
16 |
Correct |
7 ms |
4316 KB |
Output is correct |
17 |
Correct |
7 ms |
4224 KB |
Output is correct |
18 |
Correct |
7 ms |
4224 KB |
Output is correct |
19 |
Correct |
7 ms |
4224 KB |
Output is correct |
20 |
Correct |
7 ms |
4224 KB |
Output is correct |
21 |
Correct |
7 ms |
4224 KB |
Output is correct |
22 |
Correct |
8 ms |
4224 KB |
Output is correct |
23 |
Correct |
7 ms |
4224 KB |
Output is correct |
24 |
Correct |
7 ms |
4224 KB |
Output is correct |
25 |
Correct |
7 ms |
4224 KB |
Output is correct |
26 |
Correct |
7 ms |
4224 KB |
Output is correct |
27 |
Correct |
7 ms |
4224 KB |
Output is correct |
28 |
Correct |
11 ms |
4224 KB |
Output is correct |
29 |
Correct |
7 ms |
4224 KB |
Output is correct |
30 |
Correct |
8 ms |
4224 KB |
Output is correct |
31 |
Correct |
9 ms |
4224 KB |
Output is correct |
32 |
Correct |
7 ms |
4224 KB |
Output is correct |
33 |
Correct |
16 ms |
4224 KB |
Output is correct |
34 |
Correct |
8 ms |
4224 KB |
Output is correct |
35 |
Correct |
16 ms |
4224 KB |
Output is correct |
36 |
Correct |
9 ms |
4224 KB |
Output is correct |
37 |
Correct |
12 ms |
4224 KB |
Output is correct |
38 |
Correct |
9 ms |
4224 KB |
Output is correct |
39 |
Correct |
8 ms |
4224 KB |
Output is correct |
40 |
Correct |
8 ms |
4224 KB |
Output is correct |
41 |
Correct |
7 ms |
4224 KB |
Output is correct |
42 |
Correct |
8 ms |
4224 KB |
Output is correct |
43 |
Correct |
7 ms |
4224 KB |
Output is correct |
44 |
Correct |
8 ms |
4224 KB |
Output is correct |
45 |
Correct |
9 ms |
4224 KB |
Output is correct |
46 |
Correct |
8 ms |
4224 KB |
Output is correct |
47 |
Correct |
8 ms |
4224 KB |
Output is correct |
48 |
Correct |
10 ms |
4312 KB |
Output is correct |
49 |
Correct |
11 ms |
4224 KB |
Output is correct |
50 |
Correct |
11 ms |
4224 KB |
Output is correct |
51 |
Correct |
29 ms |
4224 KB |
Output is correct |
52 |
Correct |
30 ms |
4224 KB |
Output is correct |
53 |
Correct |
7 ms |
4224 KB |
Output is correct |
54 |
Correct |
14 ms |
4224 KB |
Output is correct |
55 |
Correct |
13 ms |
4224 KB |
Output is correct |
56 |
Correct |
8 ms |
4224 KB |
Output is correct |
57 |
Correct |
18 ms |
4224 KB |
Output is correct |
58 |
Correct |
9 ms |
4224 KB |
Output is correct |
59 |
Correct |
10 ms |
4224 KB |
Output is correct |
60 |
Correct |
9 ms |
4224 KB |
Output is correct |
61 |
Correct |
7 ms |
4224 KB |
Output is correct |
62 |
Correct |
16 ms |
4224 KB |
Output is correct |
63 |
Correct |
11 ms |
4224 KB |
Output is correct |
64 |
Correct |
13 ms |
4224 KB |
Output is correct |
65 |
Correct |
8 ms |
4224 KB |
Output is correct |
66 |
Correct |
8 ms |
4224 KB |
Output is correct |
67 |
Correct |
8 ms |
4224 KB |
Output is correct |
68 |
Correct |
8 ms |
4224 KB |
Output is correct |
69 |
Correct |
9 ms |
4224 KB |
Output is correct |
70 |
Correct |
11 ms |
4224 KB |
Output is correct |
71 |
Correct |
7 ms |
4224 KB |
Output is correct |
72 |
Correct |
10 ms |
4224 KB |
Output is correct |
73 |
Correct |
9 ms |
4224 KB |
Output is correct |
74 |
Correct |
11 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
4312 KB |
Output is correct |
2 |
Correct |
7 ms |
4224 KB |
Output is correct |
3 |
Correct |
7 ms |
4224 KB |
Output is correct |
4 |
Correct |
7 ms |
4224 KB |
Output is correct |
5 |
Correct |
7 ms |
4224 KB |
Output is correct |
6 |
Correct |
8 ms |
4224 KB |
Output is correct |
7 |
Correct |
7 ms |
4224 KB |
Output is correct |
8 |
Correct |
7 ms |
4224 KB |
Output is correct |
9 |
Correct |
7 ms |
4224 KB |
Output is correct |
10 |
Correct |
7 ms |
4224 KB |
Output is correct |
11 |
Correct |
7 ms |
4224 KB |
Output is correct |
12 |
Correct |
7 ms |
4224 KB |
Output is correct |
13 |
Correct |
7 ms |
4224 KB |
Output is correct |
14 |
Correct |
7 ms |
4224 KB |
Output is correct |
15 |
Correct |
7 ms |
4224 KB |
Output is correct |
16 |
Correct |
7 ms |
4224 KB |
Output is correct |
17 |
Correct |
7 ms |
4224 KB |
Output is correct |
18 |
Correct |
7 ms |
4224 KB |
Output is correct |
19 |
Correct |
7 ms |
4224 KB |
Output is correct |
20 |
Correct |
7 ms |
4224 KB |
Output is correct |
21 |
Correct |
7 ms |
4224 KB |
Output is correct |
22 |
Correct |
9 ms |
4224 KB |
Output is correct |
23 |
Correct |
7 ms |
4224 KB |
Output is correct |
24 |
Correct |
7 ms |
4224 KB |
Output is correct |
25 |
Correct |
7 ms |
4224 KB |
Output is correct |
26 |
Correct |
9 ms |
4224 KB |
Output is correct |
27 |
Correct |
7 ms |
4224 KB |
Output is correct |
28 |
Correct |
9 ms |
4224 KB |
Output is correct |
29 |
Correct |
8 ms |
4224 KB |
Output is correct |
30 |
Correct |
8 ms |
4224 KB |
Output is correct |
31 |
Correct |
7 ms |
4224 KB |
Output is correct |
32 |
Correct |
8 ms |
4224 KB |
Output is correct |
33 |
Correct |
7 ms |
4224 KB |
Output is correct |
34 |
Correct |
7 ms |
4224 KB |
Output is correct |
35 |
Correct |
8 ms |
4224 KB |
Output is correct |
36 |
Correct |
8 ms |
4224 KB |
Output is correct |
37 |
Correct |
11 ms |
4224 KB |
Output is correct |
38 |
Correct |
12 ms |
4224 KB |
Output is correct |
39 |
Correct |
12 ms |
4224 KB |
Output is correct |
40 |
Correct |
7 ms |
4224 KB |
Output is correct |
41 |
Correct |
13 ms |
4352 KB |
Output is correct |
42 |
Correct |
12 ms |
4224 KB |
Output is correct |
43 |
Correct |
8 ms |
4224 KB |
Output is correct |
44 |
Correct |
8 ms |
4224 KB |
Output is correct |
45 |
Correct |
10 ms |
4224 KB |
Output is correct |
46 |
Correct |
9 ms |
4224 KB |
Output is correct |
47 |
Correct |
9 ms |
4224 KB |
Output is correct |
48 |
Correct |
7 ms |
4224 KB |
Output is correct |
49 |
Correct |
9 ms |
4224 KB |
Output is correct |
50 |
Correct |
11 ms |
4224 KB |
Output is correct |
51 |
Correct |
1 ms |
384 KB |
Output is correct |
52 |
Correct |
9 ms |
384 KB |
Output is correct |
53 |
Correct |
15 ms |
384 KB |
Output is correct |
54 |
Correct |
30 ms |
384 KB |
Output is correct |
55 |
Correct |
27 ms |
384 KB |
Output is correct |
56 |
Correct |
101 ms |
384 KB |
Output is correct |
57 |
Correct |
101 ms |
384 KB |
Output is correct |
58 |
Correct |
112 ms |
384 KB |
Output is correct |
59 |
Correct |
112 ms |
384 KB |
Output is correct |
60 |
Incorrect |
106 ms |
384 KB |
Output isn't correct |
61 |
Halted |
0 ms |
0 KB |
- |