Submission #448254

#TimeUsernameProblemLanguageResultExecution timeMemory
448254JovanB오렌지 출하 (JOI16_ho_t1)C++17
100 / 100
79 ms820 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; ll dp[100005]; ll a[100005]; int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; ll n, m, k; cin >> n >> m >> k; for(int i=1; i<=n; i++){ cin >> a[i]; ll mn = a[i], mx = a[i]; dp[i] = dp[i-1] + k; for(int j=i-1; j>=1 && i-j+1<=m; j--){ mn = min(mn, a[j]); mx = max(mx, a[j]); dp[i] = min(dp[i], dp[j-1] + k + (i-j+1)*(mx-mn)); } } cout << dp[n] << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...