# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70465 | Diuven | 오렌지 출하 (JOI16_ho_t1) | C++14 | 139 ms | 5616 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 <cstdio>
typedef long long ll;
const int inf=2e9;
const ll linf=2e18;
ll min(ll a, ll b){ return a<b ? a : b; }
ll max(ll a, ll b){ return a>b ? a : b; }
int n, m, k, A[20010];
ll D[20010];
ll d(int i){
if(D[i]>=0) return D[i];
D[i]=linf;
for(int s=1, a=-inf, b=inf; s<=m; s++){
if(i<s) break;
a=max(a, A[i-s+1]), b=min(b, A[i-s+1]);
D[i]=min(D[i], d(i-s)+k+s*ll(a-b));
}
return D[i];
}
int main(){
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++) D[i]=-1;
D[0]=0;
printf("%lld\n", 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... |