제출 #844590

#제출 시각아이디문제언어결과실행 시간메모리
844590vjudge1Holding (COCI20_holding)C++17
110 / 110
71 ms4764 KiB
// author: erray #include <bits/stdc++.h> #ifdef DEBUG #include "debug.h" #else #define debug(...) void(37) #endif using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int N, L, R, K; cin >> N >> L >> R >> K; --L, --R; vector<int> A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } const int inf = int(1e9); int S = R - L + 1; vector<vector<int>> dp(S + 1, vector<int>(K + 1, inf)); dp[0][0] = 0; for (int i = 0; i < N; ++i) { vector<vector<int>> new_dp = dp; for (int j = 0; j < S; ++j) { int cost = abs(L + j - i); for (int c = 0; c + cost <= K; ++c) { int& go = new_dp[j + 1][cost + c]; int& from = dp[j][c]; go = min(go, from + A[i]); } } swap(dp, new_dp); debug(dp); } cout << (*min_element(dp[S].begin(), dp[S].end())) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...