// 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, min(k, 5000)) << 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 |
25180 KB |
Output is correct |
3 |
Correct |
3 ms |
25180 KB |
Output is correct |
4 |
Correct |
3 ms |
25180 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Correct |
3 ms |
23128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25180 KB |
Output is correct |
3 |
Correct |
3 ms |
25180 KB |
Output is correct |
4 |
Correct |
3 ms |
25180 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Correct |
3 ms |
23128 KB |
Output is correct |
8 |
Correct |
14 ms |
99084 KB |
Output is correct |
9 |
Correct |
10 ms |
98904 KB |
Output is correct |
10 |
Correct |
11 ms |
98904 KB |
Output is correct |
11 |
Correct |
12 ms |
98904 KB |
Output is correct |
12 |
Correct |
11 ms |
98908 KB |
Output is correct |
13 |
Correct |
12 ms |
98904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25180 KB |
Output is correct |
3 |
Correct |
3 ms |
25180 KB |
Output is correct |
4 |
Correct |
3 ms |
25180 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Correct |
3 ms |
23128 KB |
Output is correct |
8 |
Correct |
14 ms |
99084 KB |
Output is correct |
9 |
Correct |
10 ms |
98904 KB |
Output is correct |
10 |
Correct |
11 ms |
98904 KB |
Output is correct |
11 |
Correct |
12 ms |
98904 KB |
Output is correct |
12 |
Correct |
11 ms |
98908 KB |
Output is correct |
13 |
Correct |
12 ms |
98904 KB |
Output is correct |
14 |
Correct |
10 ms |
98904 KB |
Output is correct |
15 |
Correct |
11 ms |
98904 KB |
Output is correct |
16 |
Correct |
11 ms |
98908 KB |
Output is correct |
17 |
Correct |
11 ms |
98908 KB |
Output is correct |
18 |
Correct |
13 ms |
98908 KB |
Output is correct |
19 |
Correct |
13 ms |
98908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
3 ms |
25180 KB |
Output is correct |
3 |
Correct |
3 ms |
25180 KB |
Output is correct |
4 |
Correct |
3 ms |
25180 KB |
Output is correct |
5 |
Correct |
3 ms |
25176 KB |
Output is correct |
6 |
Correct |
3 ms |
25176 KB |
Output is correct |
7 |
Correct |
3 ms |
23128 KB |
Output is correct |
8 |
Correct |
14 ms |
99084 KB |
Output is correct |
9 |
Correct |
10 ms |
98904 KB |
Output is correct |
10 |
Correct |
11 ms |
98904 KB |
Output is correct |
11 |
Correct |
12 ms |
98904 KB |
Output is correct |
12 |
Correct |
11 ms |
98908 KB |
Output is correct |
13 |
Correct |
12 ms |
98904 KB |
Output is correct |
14 |
Correct |
10 ms |
98904 KB |
Output is correct |
15 |
Correct |
11 ms |
98904 KB |
Output is correct |
16 |
Correct |
11 ms |
98908 KB |
Output is correct |
17 |
Correct |
11 ms |
98908 KB |
Output is correct |
18 |
Correct |
13 ms |
98908 KB |
Output is correct |
19 |
Correct |
13 ms |
98908 KB |
Output is correct |
20 |
Correct |
27 ms |
199616 KB |
Output is correct |
21 |
Correct |
23 ms |
199516 KB |
Output is correct |
22 |
Correct |
24 ms |
199432 KB |
Output is correct |
23 |
Correct |
22 ms |
199520 KB |
Output is correct |
24 |
Correct |
31 ms |
199592 KB |
Output is correct |
25 |
Correct |
58 ms |
199892 KB |
Output is correct |