Submission #906311

#TimeUsernameProblemLanguageResultExecution timeMemory
906311OAleksa오렌지 출하 (JOI16_ho_t1)C++14
100 / 100
42 ms756 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define f first #define s second const int N = 2e4 + 69; int dp[N], n, a[N], k, m; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { cin >> n >> m >> k; for (int i = 1;i <= n;i++) { cin >> a[i]; dp[i] = 1e18; } for (int i = 1;i <= n;i++) { int mx = a[i], mn = a[i]; for (int j = i - 1;j >= max(0ll, i - m);j--) { dp[i] = min(dp[i], dp[j] + k + (i - j) * (mx - mn)); mx = max(mx, a[j]); mn = min(mn, a[j]); } } cout << dp[n]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...