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>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;
int n,l,r,k,dp[110][110][10010],a[110];
bool use[110][110][10010];
int fn(int pos,int cuantos,int m){
    if( cuantos==r-l+1 ) return 0;
    if( pos > n ) return 1+1e8;
    if( use[pos][cuantos][m] ) return dp[pos][cuantos][m];
    use[pos][cuantos][m] = true;
    int myAns = 0;
    myAns = fn( pos+1 , cuantos , m );
    if( m >= abs(l+cuantos-pos) ) myAns = min( myAns , a[pos]+fn( pos+1 , cuantos+1 , m-abs( l+cuantos-pos ) ) );
    return dp[pos][cuantos][m] = myAns;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> l >> r >> k;
    for(int i=1; i<=n; i++) cin >> a[i];
    cout << fn( 1 , 0 , k );
    return 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... |