#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<61);
const int MX=2009;
ll n,A,B;
ll a[MX],dp[MX],ans,sum1,dp1[109][109];
ll DP(ll x){
if(x==n)return 0;
ll &ret=dp[x];if(ret!=-1)return ret;
ret=inf;
ll sum=0;
for(int i=x;i<n;i++){
sum+=a[i];
if((sum&sum1)==0){
ret=min(ret,DP(i+1)+1);
}
}
return ret;
}
ll DP1(ll x,ll y){
if(y>B)return 0;
if(x==n)return (y>=A);
ll &ret=dp1[x][y];if(ret!=-1)return ret;
ret=0;
ll sum=0;
for(int i=x;i<n;i++){
sum+=a[i];
if((sum&sum1)==0){
ret=max(ret,DP1(i+1,y+1));
}
}
return ret;
}
int main(){
cin>>n>>A>>B;
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
if(A==1){
for(ll i=48;i>=0;i--){
memset(dp,-1,sizeof(dp));
sum1+=(1ll<<i);
if(DP(0)<=B)continue;
ans+=(1ll<<i);
sum1-=(1ll<<i);
}
cout<<ans<<endl;
return 0;
}
for(ll i=48;i>=0;i--){
sum1+=(1ll<<i);
memset(dp1,-1,sizeof(dp1));
if(DP1(0,0)!=0)continue;
ans+=sum1;
sum1-=(1ll<<i);
}
cout<<ans<<endl;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:38:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
352 KB |
Output is correct |
3 |
Correct |
2 ms |
404 KB |
Output is correct |
4 |
Correct |
2 ms |
520 KB |
Output is correct |
5 |
Correct |
2 ms |
596 KB |
Output is correct |
6 |
Correct |
2 ms |
596 KB |
Output is correct |
7 |
Correct |
2 ms |
596 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
2 ms |
664 KB |
Output is correct |
10 |
Correct |
2 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
664 KB |
Output is correct |
12 |
Correct |
1 ms |
664 KB |
Output is correct |
13 |
Correct |
1 ms |
664 KB |
Output is correct |
14 |
Incorrect |
2 ms |
664 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
664 KB |
Output is correct |
2 |
Correct |
2 ms |
664 KB |
Output is correct |
3 |
Correct |
1 ms |
664 KB |
Output is correct |
4 |
Correct |
1 ms |
664 KB |
Output is correct |
5 |
Correct |
1 ms |
664 KB |
Output is correct |
6 |
Correct |
1 ms |
664 KB |
Output is correct |
7 |
Correct |
2 ms |
664 KB |
Output is correct |
8 |
Correct |
2 ms |
664 KB |
Output is correct |
9 |
Correct |
1 ms |
664 KB |
Output is correct |
10 |
Correct |
1 ms |
664 KB |
Output is correct |
11 |
Correct |
2 ms |
664 KB |
Output is correct |
12 |
Correct |
1 ms |
664 KB |
Output is correct |
13 |
Correct |
2 ms |
728 KB |
Output is correct |
14 |
Incorrect |
2 ms |
728 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
728 KB |
Output is correct |
2 |
Correct |
2 ms |
728 KB |
Output is correct |
3 |
Correct |
2 ms |
728 KB |
Output is correct |
4 |
Correct |
2 ms |
728 KB |
Output is correct |
5 |
Correct |
2 ms |
728 KB |
Output is correct |
6 |
Correct |
2 ms |
728 KB |
Output is correct |
7 |
Correct |
2 ms |
728 KB |
Output is correct |
8 |
Correct |
2 ms |
728 KB |
Output is correct |
9 |
Correct |
2 ms |
728 KB |
Output is correct |
10 |
Correct |
2 ms |
728 KB |
Output is correct |
11 |
Correct |
2 ms |
728 KB |
Output is correct |
12 |
Correct |
2 ms |
728 KB |
Output is correct |
13 |
Correct |
2 ms |
728 KB |
Output is correct |
14 |
Correct |
2 ms |
728 KB |
Output is correct |
15 |
Correct |
1 ms |
728 KB |
Output is correct |
16 |
Correct |
2 ms |
728 KB |
Output is correct |
17 |
Correct |
2 ms |
728 KB |
Output is correct |
18 |
Correct |
2 ms |
728 KB |
Output is correct |
19 |
Correct |
2 ms |
728 KB |
Output is correct |
20 |
Correct |
2 ms |
732 KB |
Output is correct |
21 |
Correct |
2 ms |
732 KB |
Output is correct |
22 |
Correct |
2 ms |
732 KB |
Output is correct |
23 |
Correct |
2 ms |
732 KB |
Output is correct |
24 |
Correct |
2 ms |
732 KB |
Output is correct |
25 |
Correct |
2 ms |
732 KB |
Output is correct |
26 |
Correct |
2 ms |
732 KB |
Output is correct |
27 |
Correct |
2 ms |
732 KB |
Output is correct |
28 |
Correct |
2 ms |
732 KB |
Output is correct |
29 |
Correct |
2 ms |
732 KB |
Output is correct |
30 |
Correct |
2 ms |
732 KB |
Output is correct |
31 |
Correct |
3 ms |
732 KB |
Output is correct |
32 |
Correct |
2 ms |
732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
732 KB |
Output is correct |
2 |
Correct |
1 ms |
732 KB |
Output is correct |
3 |
Correct |
1 ms |
732 KB |
Output is correct |
4 |
Correct |
1 ms |
732 KB |
Output is correct |
5 |
Correct |
1 ms |
732 KB |
Output is correct |
6 |
Correct |
1 ms |
732 KB |
Output is correct |
7 |
Correct |
1 ms |
732 KB |
Output is correct |
8 |
Correct |
2 ms |
732 KB |
Output is correct |
9 |
Correct |
2 ms |
732 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
11 |
Correct |
1 ms |
732 KB |
Output is correct |
12 |
Correct |
1 ms |
732 KB |
Output is correct |
13 |
Correct |
2 ms |
732 KB |
Output is correct |
14 |
Incorrect |
2 ms |
732 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
732 KB |
Output is correct |
2 |
Correct |
1 ms |
732 KB |
Output is correct |
3 |
Correct |
1 ms |
732 KB |
Output is correct |
4 |
Correct |
1 ms |
732 KB |
Output is correct |
5 |
Correct |
1 ms |
732 KB |
Output is correct |
6 |
Correct |
1 ms |
732 KB |
Output is correct |
7 |
Correct |
2 ms |
732 KB |
Output is correct |
8 |
Correct |
1 ms |
732 KB |
Output is correct |
9 |
Correct |
1 ms |
732 KB |
Output is correct |
10 |
Correct |
1 ms |
732 KB |
Output is correct |
11 |
Correct |
1 ms |
732 KB |
Output is correct |
12 |
Correct |
1 ms |
732 KB |
Output is correct |
13 |
Correct |
2 ms |
732 KB |
Output is correct |
14 |
Correct |
1 ms |
732 KB |
Output is correct |
15 |
Correct |
1 ms |
736 KB |
Output is correct |
16 |
Correct |
1 ms |
736 KB |
Output is correct |
17 |
Correct |
1 ms |
736 KB |
Output is correct |
18 |
Correct |
1 ms |
736 KB |
Output is correct |
19 |
Correct |
2 ms |
736 KB |
Output is correct |
20 |
Correct |
2 ms |
736 KB |
Output is correct |
21 |
Correct |
2 ms |
736 KB |
Output is correct |
22 |
Correct |
2 ms |
736 KB |
Output is correct |
23 |
Correct |
1 ms |
736 KB |
Output is correct |
24 |
Correct |
2 ms |
736 KB |
Output is correct |
25 |
Correct |
2 ms |
736 KB |
Output is correct |
26 |
Correct |
2 ms |
736 KB |
Output is correct |
27 |
Correct |
2 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
736 KB |
Output is correct |
29 |
Correct |
2 ms |
736 KB |
Output is correct |
30 |
Correct |
2 ms |
736 KB |
Output is correct |
31 |
Correct |
2 ms |
736 KB |
Output is correct |
32 |
Correct |
2 ms |
736 KB |
Output is correct |
33 |
Correct |
2 ms |
736 KB |
Output is correct |
34 |
Correct |
2 ms |
736 KB |
Output is correct |
35 |
Correct |
2 ms |
736 KB |
Output is correct |
36 |
Correct |
2 ms |
736 KB |
Output is correct |
37 |
Correct |
2 ms |
736 KB |
Output is correct |
38 |
Correct |
2 ms |
736 KB |
Output is correct |
39 |
Correct |
2 ms |
736 KB |
Output is correct |
40 |
Correct |
2 ms |
736 KB |
Output is correct |
41 |
Correct |
2 ms |
736 KB |
Output is correct |
42 |
Correct |
3 ms |
736 KB |
Output is correct |
43 |
Correct |
1 ms |
736 KB |
Output is correct |
44 |
Correct |
2 ms |
736 KB |
Output is correct |
45 |
Correct |
2 ms |
736 KB |
Output is correct |
46 |
Correct |
2 ms |
736 KB |
Output is correct |
47 |
Correct |
3 ms |
736 KB |
Output is correct |
48 |
Correct |
2 ms |
736 KB |
Output is correct |
49 |
Correct |
2 ms |
736 KB |
Output is correct |
50 |
Correct |
2 ms |
736 KB |
Output is correct |
51 |
Correct |
2 ms |
736 KB |
Output is correct |
52 |
Correct |
14 ms |
736 KB |
Output is correct |
53 |
Correct |
15 ms |
736 KB |
Output is correct |
54 |
Correct |
51 ms |
748 KB |
Output is correct |
55 |
Correct |
35 ms |
748 KB |
Output is correct |
56 |
Correct |
113 ms |
748 KB |
Output is correct |
57 |
Correct |
101 ms |
748 KB |
Output is correct |
58 |
Correct |
128 ms |
748 KB |
Output is correct |
59 |
Correct |
134 ms |
748 KB |
Output is correct |
60 |
Correct |
106 ms |
748 KB |
Output is correct |
61 |
Correct |
2 ms |
748 KB |
Output is correct |
62 |
Correct |
15 ms |
748 KB |
Output is correct |
63 |
Correct |
47 ms |
748 KB |
Output is correct |
64 |
Correct |
28 ms |
748 KB |
Output is correct |
65 |
Correct |
49 ms |
748 KB |
Output is correct |
66 |
Correct |
77 ms |
748 KB |
Output is correct |
67 |
Correct |
109 ms |
748 KB |
Output is correct |
68 |
Correct |
184 ms |
752 KB |
Output is correct |
69 |
Correct |
92 ms |
752 KB |
Output is correct |