# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146748 | TadijaSebez | 오렌지 출하 (JOI16_ho_t1) | C++11 | 67 ms | 888 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;
#define ll long long
const int N=20050;
const ll inf=9e18;
void ckmn(ll &a, ll b){ a=min(a,b);}
void ckmn(int &a, int b){ a=min(a,b);}
void ckmx(int &a, int b){ a=max(a,b);}
int a[N];
ll dp[N];
int main()
{
int n,m,k;
scanf("%i %i %i",&n,&m,&k);
for(int i=1;i<=n;i++)
{
scanf("%i",&a[i]);
int mx=a[i],mn=a[i];
dp[i]=inf;
for(int j=i;j>=1 && i-j+1<=m;j--)
{
ckmn(mn,a[j]);
ckmx(mx,a[j]);
ckmn(dp[i],dp[j-1]+k+(ll)(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... |