# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335771 | ChrisT | 오렌지 출하 (JOI16_ho_t1) | C++17 | 23 ms | 620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MN = 1e4 + 5;
int a[MN];long long dp[MN];
int main() {
int n,m,k;
scanf ("%d %d %d",&n,&m,&k);
for (int i = 1; i <= n; i++) {
scanf ("%d",&a[i]); int mx = a[i], mn = a[i]; dp[i] = 2e18;
for (int j = i; j >= max(1,i-m+1); j--) {
mx = max(mx,a[j]); mn = min(mn,a[j]);
dp[i] = min(dp[i],dp[j-1] + k + (long long)(i-j+1) * (mx - mn));
}
}
printf ("%lld\n",dp[n]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |