Submission #844307

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
8443072023-09-05 12:12:33vjudge1Holding (COCI20_holding)C++17
110 / 110
92 ms4560 KiB
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define int long long
using namespace std;
const int inf = 2e18 + 5;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int32_t main(){
//freopen("in.txt","r", stdin);
int n, l, r, k;
cin>>n>>l>>r>>k;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
// dp[r - l + 1][k] = cost
vector<vector<int> > dp(r - l + 1 + 1, vector<int>(k+1, inf));
for(int i = 0; i <= k; i++) dp[0][i] = 0;
for(int i = 0; i < n; i++){
for(int j = r - l; j >= 0; j--){
for(int co = 0; co <= k; co++){
if(abs(i - (j + l - 1)) <= co) dp[j+1][co - abs(i - (j + l - 1))] = min(dp[j+1][co - abs(i - (j + l - 1))], dp[j][co] + a[i]);
}
}
}
cout<<dp[r-l+1][0]<<endl;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...