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>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
using ll = long long;
constexpr ll inf = std::numeric_limits<ll>::max() / 2;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, L, R, K;
std::cin >> N >> L >> R >> K;
L -= 1;
vector dp(R - L + 1, vector(K + 1, inf));
dp[0][0] = 0;
for (int i = 0; i < N; ++i) {
int a;
std::cin >> a;
for (int j = R - L - 1; j >= 0; --j) {
for (int k = K; k >= 0; --k) {
const int d = std::abs(i - (j + L));
if (k + d <= K) {
dp[j + 1][k + d] = std::min(dp[j + 1][k + d], dp[j][k] + a);
}
}
}
}
std::cout << *std::min_element(dp[R - L].begin(), dp[R - L].end()) << '\n';
return 0;
}
# | 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... |