# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58739 | leejseo | 오렌지 출하 (JOI16_ho_t1) | C++98 | 85 ms | 3600 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;
typedef long long lld;
const lld UNDEF = 1LL << 60;
const int MAXN = 20000;
int N, M;
lld K, A[MAXN+1], D[MAXN+1];
void input(){
scanf("%d%d%lld", &N, &M, &K);
for (int i=0; i<N; i++) scanf("%lld", &A[i+1]);
}
void DP(){
D[0] = 0;
for (int i=1; i<=N; i++){
D[i] = D[i-1]+K;
lld m1 = A[i], m2 = A[i];
for (int k=i-1; k > max(0,i-M); k--){
m1 = max(m1, A[k]), m2 = min(m2, A[k]);
D[i] = min(D[i], D[k-1] + K + (i-k+1) * (m1 - m2));
}
}
printf("%lld\n", D[N]);
}
int main(){
input();
DP();
}
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... |