#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,l,r;
ll a[2020];
ll dp[350][350][350];
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(){
cin>>n>>l>>r;
for(ll i=0;i<n;i++){
cin>>a[i];
}
memset(dp,-1,sizeof dp);
cout<<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(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
191 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
212 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
217 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
242 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
236 ms |
263168 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |