Submission #202369

#TimeUsernameProblemLanguageResultExecution timeMemory
202369EmmanuelACHolding (COCI20_holding)C++14
110 / 110
140 ms44408 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...