# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287461 | Namnamseo | 오렌지 출하 (JOI16_ho_t1) | C++17 | 85 ms | 924 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>
int n,m,k;
int data[20010];
typedef long long ll;
ll dp[20010];
template<typename T> inline T max(T a,T b){ return b<a?a:b; }
template<typename T> inline T min(T a,T b){ return a<b?a:b; }
int main()
{
scanf("%d%d%d",&n,&m,&k);
int i,j;
int Mx, mn;
for(i=1;i<=n;++i){
scanf("%d",data+i);
Mx=mn=data[i];
dp[i]=(1LL<<61);
for(j=i;j && i-j<m;--j){
Mx=max(Mx,data[j]);
mn=min(mn,data[j]);
dp[i]=min(dp[i], dp[j-1]+k+ll(i-j+1)*(Mx-mn));
}
}
printf("%lld",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... |