This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int mxN = 105;
long long dp[mxN][mxN];
int a, b, n;
vector<int>v;
long long rec(int indx, int x){
long long res = 1e15, sum = 0;
if(indx == n && x >= a && x <= b)return 0;
if(indx == n)return 1e15;
if(dp[indx][x] != -1)return dp[indx][x];
for(int i = indx;i < n;++i){
sum += v[i];
res = min(res, sum | rec(i + 1, x + 1));
}
return dp[indx][x] = res;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> a >> b;
v.resize(n);
for(int i = 0;i < mxN;++i){
for(int j = 0;j < mxN;++j){
dp[i][j] = -1;
}
}
for(int i = 0;i < n;++i){
cin >> v[i];
}
cout << rec(0, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |