Submission #995264

#TimeUsernameProblemLanguageResultExecution timeMemory
995264gmroh06오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
37 ms900 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; inline void fastio(); ll n, m, k; ll a[20005], dp[20005]; int main() { fastio(); cin >> n >> m >> k; for (ll i = 1; i <= n; i++) { cin >> a[i]; dp[i] = 9e18; } for (ll i = 1; i <= n; i++) { ll mins = a[i], maxs = a[i]; for (ll j = 1; j <= i and j <= m; j++) { mins = min(mins, a[i - j + 1]); maxs = max(maxs, a[i - j + 1]); dp[i] = min(dp[i], dp[i - j] + j * (maxs - mins) + k); } } cout << dp[n] << '\n'; } inline void fastio() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...