This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define int long long int
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 1e6 + 5;
int a[105];
int n, l, r, k;
int dp[105][105][10005];
int rec(int in, int in2, int left){
if(in2 == r) return 0;
if(in == n) return MOD;
if(dp[in][in2][left] != -1) return dp[in][in2][left];
int ans1 = rec(in+1, in2, left), ans2 = MOD;
if(abs(in - in2) <= left) ans2 = rec(in+1, in2+1, left - abs(in - in2)) + a[in];
return dp[in][in2][left] = min(ans1, ans2);
}
inline void solve(){
cin >> n >> l >> r >> k;
for(int i = 0; i < n; i++) cin >> a[i];
rep(i, 0, n) rep(j, 0, n) rep(ll, 0, k+1) dp[i][j][ll] = -1;
cout << rec(0, l-1, k) << endl;
}
int32_t main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
# | 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... |