// 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 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[101];
int n, l, r, k;
int dp[101][101][5001];
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, 5001) dp[i][j][ll] = -1;
cout << rec(0, l-1, k) << endl;
}
int main(){
fast_io
int t;
t = 1;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25176 KB |
Output is correct |
3 |
Correct |
3 ms |
25176 KB |
Output is correct |
4 |
Correct |
3 ms |
25176 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Incorrect |
3 ms |
23132 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25176 KB |
Output is correct |
3 |
Correct |
3 ms |
25176 KB |
Output is correct |
4 |
Correct |
3 ms |
25176 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Incorrect |
3 ms |
23132 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25176 KB |
Output is correct |
3 |
Correct |
3 ms |
25176 KB |
Output is correct |
4 |
Correct |
3 ms |
25176 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Incorrect |
3 ms |
23132 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25176 KB |
Output is correct |
3 |
Correct |
3 ms |
25176 KB |
Output is correct |
4 |
Correct |
3 ms |
25176 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Incorrect |
3 ms |
23132 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |