#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,arr[59];
ll dp[59][509];
ll bt(ll id,ll sum,ll curr,ll flag,bool flag2){
if(id == n){
if(flag < a || flag > b || !flag2) return 1000000009;
return curr;
}
ll &ret = dp[id][sum];
if(ret != -1) return ret;
ret = 1000000009;
sum += arr[id];
ret = min(ret,bt(id+1,sum,curr,flag,0));
curr |= sum;
ret = min(ret,bt(id+1,0,curr,flag+1,1));
return ret;
}
int main(){
cin>>n>>a>>b;
for(int i=0;i<n;i++) cin>>arr[i];
memset(dp,-1,sizeof(dp));
cout<<bt(0,0,0,0,0)<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
684 KB |
Output is correct |
2 |
Incorrect |
3 ms |
512 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |