#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,l,r;
ll a[111];
ll dp[111][111][111];
ll solve(ll i,ll last,ll k,ll sum){
//cout<<"call: "<<i<<' '<<last<<' '<<k<<' '<<sum<<endl;
if(i==n){
if(k>=l&&k<=r&&last==n)return 0;
return -2;
}
ll &ans=dp[i][last][k];
sum+=a[i];
if(ans!=-1)return ans;
ll ans1=solve(i+1,last,k,sum),ans2=solve(i+1,i+1,k+1,0);
if(ans1==-2&&ans2==-2)return ans=-2;
if(ans1==-2)return ans=ans2|sum;
if(ans2==-2)return ans=ans1;
return ans=min(ans1,ans2|sum);
}
main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>l>>r;
for(ll i=0;i<n;i++){
cin>>a[i];
}
memset(dp,-1,sizeof dp);
cout<<max(0ll,solve(0,0,0,0))<<endl;
return 0;
}
Compilation message
sculpture.cpp:25:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
11000 KB |
Output is correct |
2 |
Correct |
12 ms |
11008 KB |
Output is correct |
3 |
Correct |
12 ms |
11008 KB |
Output is correct |
4 |
Correct |
12 ms |
11008 KB |
Output is correct |
5 |
Correct |
14 ms |
11136 KB |
Output is correct |
6 |
Correct |
12 ms |
11008 KB |
Output is correct |
7 |
Correct |
11 ms |
11008 KB |
Output is correct |
8 |
Correct |
13 ms |
11008 KB |
Output is correct |
9 |
Correct |
11 ms |
11008 KB |
Output is correct |
10 |
Correct |
11 ms |
11008 KB |
Output is correct |
11 |
Correct |
11 ms |
11036 KB |
Output is correct |
12 |
Correct |
11 ms |
11008 KB |
Output is correct |
13 |
Correct |
11 ms |
11008 KB |
Output is correct |
14 |
Correct |
11 ms |
11008 KB |
Output is correct |
15 |
Correct |
12 ms |
11024 KB |
Output is correct |
16 |
Correct |
11 ms |
11008 KB |
Output is correct |
17 |
Correct |
11 ms |
11008 KB |
Output is correct |
18 |
Correct |
38 ms |
11008 KB |
Output is correct |
19 |
Correct |
11 ms |
11008 KB |
Output is correct |
20 |
Correct |
11 ms |
11008 KB |
Output is correct |
21 |
Incorrect |
13 ms |
11008 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
11008 KB |
Output is correct |
2 |
Correct |
12 ms |
11008 KB |
Output is correct |
3 |
Correct |
12 ms |
11008 KB |
Output is correct |
4 |
Correct |
12 ms |
11008 KB |
Output is correct |
5 |
Correct |
20 ms |
11008 KB |
Output is correct |
6 |
Correct |
12 ms |
11008 KB |
Output is correct |
7 |
Correct |
12 ms |
10984 KB |
Output is correct |
8 |
Correct |
13 ms |
11008 KB |
Output is correct |
9 |
Correct |
12 ms |
10980 KB |
Output is correct |
10 |
Correct |
14 ms |
11008 KB |
Output is correct |
11 |
Correct |
13 ms |
11008 KB |
Output is correct |
12 |
Correct |
13 ms |
11008 KB |
Output is correct |
13 |
Correct |
12 ms |
11008 KB |
Output is correct |
14 |
Correct |
13 ms |
11008 KB |
Output is correct |
15 |
Correct |
13 ms |
11008 KB |
Output is correct |
16 |
Correct |
12 ms |
11008 KB |
Output is correct |
17 |
Correct |
12 ms |
11008 KB |
Output is correct |
18 |
Correct |
13 ms |
11008 KB |
Output is correct |
19 |
Correct |
13 ms |
11008 KB |
Output is correct |
20 |
Correct |
11 ms |
11008 KB |
Output is correct |
21 |
Incorrect |
12 ms |
10980 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
11008 KB |
Output is correct |
2 |
Correct |
11 ms |
11008 KB |
Output is correct |
3 |
Correct |
12 ms |
11008 KB |
Output is correct |
4 |
Correct |
12 ms |
11052 KB |
Output is correct |
5 |
Correct |
11 ms |
11136 KB |
Output is correct |
6 |
Correct |
13 ms |
11008 KB |
Output is correct |
7 |
Correct |
11 ms |
11008 KB |
Output is correct |
8 |
Correct |
11 ms |
11008 KB |
Output is correct |
9 |
Correct |
12 ms |
11008 KB |
Output is correct |
10 |
Correct |
11 ms |
11008 KB |
Output is correct |
11 |
Correct |
12 ms |
11008 KB |
Output is correct |
12 |
Correct |
12 ms |
11008 KB |
Output is correct |
13 |
Correct |
11 ms |
11008 KB |
Output is correct |
14 |
Correct |
12 ms |
10980 KB |
Output is correct |
15 |
Correct |
11 ms |
11008 KB |
Output is correct |
16 |
Correct |
13 ms |
11008 KB |
Output is correct |
17 |
Correct |
13 ms |
11008 KB |
Output is correct |
18 |
Correct |
12 ms |
11008 KB |
Output is correct |
19 |
Correct |
12 ms |
11008 KB |
Output is correct |
20 |
Correct |
12 ms |
11008 KB |
Output is correct |
21 |
Correct |
12 ms |
11008 KB |
Output is correct |
22 |
Correct |
12 ms |
11008 KB |
Output is correct |
23 |
Correct |
12 ms |
11008 KB |
Output is correct |
24 |
Correct |
11 ms |
11008 KB |
Output is correct |
25 |
Correct |
14 ms |
11008 KB |
Output is correct |
26 |
Correct |
12 ms |
11008 KB |
Output is correct |
27 |
Correct |
13 ms |
11008 KB |
Output is correct |
28 |
Correct |
14 ms |
11008 KB |
Output is correct |
29 |
Correct |
15 ms |
11008 KB |
Output is correct |
30 |
Correct |
14 ms |
11008 KB |
Output is correct |
31 |
Correct |
15 ms |
11008 KB |
Output is correct |
32 |
Correct |
14 ms |
11008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
11008 KB |
Output is correct |
2 |
Correct |
12 ms |
11008 KB |
Output is correct |
3 |
Correct |
12 ms |
11008 KB |
Output is correct |
4 |
Correct |
11 ms |
11008 KB |
Output is correct |
5 |
Correct |
13 ms |
11008 KB |
Output is correct |
6 |
Correct |
12 ms |
11136 KB |
Output is correct |
7 |
Correct |
12 ms |
11008 KB |
Output is correct |
8 |
Correct |
12 ms |
11008 KB |
Output is correct |
9 |
Correct |
12 ms |
11136 KB |
Output is correct |
10 |
Correct |
12 ms |
11008 KB |
Output is correct |
11 |
Correct |
12 ms |
11008 KB |
Output is correct |
12 |
Correct |
12 ms |
11008 KB |
Output is correct |
13 |
Correct |
11 ms |
11008 KB |
Output is correct |
14 |
Correct |
11 ms |
11008 KB |
Output is correct |
15 |
Correct |
12 ms |
11008 KB |
Output is correct |
16 |
Correct |
13 ms |
11008 KB |
Output is correct |
17 |
Correct |
11 ms |
11084 KB |
Output is correct |
18 |
Correct |
12 ms |
11008 KB |
Output is correct |
19 |
Correct |
11 ms |
11008 KB |
Output is correct |
20 |
Correct |
12 ms |
11008 KB |
Output is correct |
21 |
Incorrect |
13 ms |
11008 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
11008 KB |
Output is correct |
2 |
Correct |
11 ms |
11008 KB |
Output is correct |
3 |
Correct |
12 ms |
11084 KB |
Output is correct |
4 |
Correct |
11 ms |
11048 KB |
Output is correct |
5 |
Correct |
11 ms |
11008 KB |
Output is correct |
6 |
Correct |
13 ms |
11008 KB |
Output is correct |
7 |
Correct |
12 ms |
11136 KB |
Output is correct |
8 |
Correct |
13 ms |
11008 KB |
Output is correct |
9 |
Correct |
13 ms |
11136 KB |
Output is correct |
10 |
Correct |
13 ms |
11008 KB |
Output is correct |
11 |
Correct |
12 ms |
11008 KB |
Output is correct |
12 |
Correct |
11 ms |
11008 KB |
Output is correct |
13 |
Correct |
13 ms |
11008 KB |
Output is correct |
14 |
Correct |
12 ms |
11008 KB |
Output is correct |
15 |
Correct |
12 ms |
11008 KB |
Output is correct |
16 |
Correct |
12 ms |
11008 KB |
Output is correct |
17 |
Correct |
12 ms |
11008 KB |
Output is correct |
18 |
Incorrect |
12 ms |
11008 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |