# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117156 | onjo0127 | 오렌지 출하 (JOI16_ho_t1) | C++11 | 42 ms | 780 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 INF = 1e9;
int A[20009];
long long D[20009];
int main() {
int N, M, K; scanf("%d%d%d",&N,&M,&K);
for(int i=1; i<=N; i++) scanf("%d",&A[i]);
for(int i=1; i<=N; i++) {
int mx = -INF, mn = INF;
D[i] = 1LL * 1e18;
for(int j=i-1; j>=max(0, i-M); j--) {
mx = max(mx, A[j+1]);
mn = min(mn, A[j+1]);
D[i] = min(D[i], D[j] + K + 1LL * (i-j) * (mx-mn));
}
}
printf("%lld", D[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... |