# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844307 | vjudge1 | Holding (COCI20_holding) | C++17 | 92 ms | 4560 KiB |
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 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;
# | 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... |