| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1157552 | mocha | 오렌지 출하 (JOI16_ho_t1) | C++20 | 32 ms | 692 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf = 1e18;
int n, m, k;
int a[20005];
int ma[20][20005], mn[20][20005];
int dp[20005];
int ans;
signed main() {
cin >> n >> m >> k;
for (int i=1;i<=n;i++) cin >> a[i];
dp[0] = 0;
int ma, mn;
for (int i=1;i<=n;i++) {
ma = mn = a[i];
dp[i] = k + ma - mn + dp[i-1];
for (int j=i;j>=max(1ll, i-m+1);j--) {
ma = max(a[j], ma), mn = min(a[j], mn);
dp[i] = min(dp[i], k + (i-j+1)*(ma-mn) + dp[j-1]);
}
}
cout << dp[n] << "\n";
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
