Submission #844330

#TimeUsernameProblemLanguageResultExecution timeMemory
844330NotLinuxHolding (COCI20_holding)C++17
0 / 110
16 ms17244 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 105; const int M = 10005; const int inf = 1e18 + 7; int dp[M+1][N+1],ndp[M+1][N+1];//0 indexli void solve(){ int n,l,r,k;cin >> n >> l >> r >> k; l--;r--; int arr[n]; for(int i = 0;i<n;i++)cin >> arr[i]; for(int j = 0;j<=M;j++){ for(int k = 0;k<=N;k++){ dp[j][k] = inf; ndp[j][k] = inf; } } dp[k][0] = 0; for(int i = 0;i<n;i++){ for(int j = 0;j<M;j++){ for(int k = 0;k<=(r-l+1);k++){ if(dp[j][k] == inf)continue; //cout << i << " " << j << " " << k << " = " << dp[i][j][k] << " " << (j - abs((l + k) - i)) << endl; //al if((j - abs((l + k) - i)) >= 0){ ndp[(j - abs((l + k) - i))][k+1] = min(ndp[(j - abs((l + k) - i))][k+1] , dp[j][k] + arr[i]); //cout << " -> " << i+1 << " " << (j - abs((l + k) - i)) << " " << k+1 << " = " << dp[i+1][(j - abs((l + k) - i))][k+1] << endl; } //alma ndp[j][k] = min(ndp[j][k] , dp[j][k]); } } for(int j = 0;j<=M;j++){ for(int k = 0;k<=N;k++){ dp[j][k] = ndp[j][k]; } } } int ans = inf; //cout << "ENDED" << endl; for(int i = 0;i<N;i++){ //cout << n << " " << i << " " << r-l+1 << " -> " << dp[n][i][r-l+1] << endl; ans = min(ans , dp[i][r-l+1]); } cout << ans << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...