# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136936 | arnold518 | 오렌지 출하 (JOI16_ho_t1) | C++14 | 68 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e4;
int N, M;
ll K, A[MAXN+10], dp[MAXN+10];
int main()
{
int i, j;
scanf("%d%d%lld", &N, &M, &K);
for(i=1; i<=N; i++) scanf("%lld", &A[i]);
for(i=1; i<=N; i++)
{
ll a=A[i], b=A[i], s=0;
dp[i]=numeric_limits<ll>::max();
for(j=i; j>=1 && i-j+1<=M; j--)
{
a=max(A[j], a);
b=min(A[j], b);
s++;
dp[i]=min(dp[i], dp[j-1]+K+s*(a-b));
}
}
printf("%lld", dp[N]);
}
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... |