# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51656 | gs13105 | 오렌지 출하 (JOI16_ho_t1) | C++17 | 96 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>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
using namespace std;
int arr[20010];
long long mem[20010];
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int n, m, k, i, j;
scanf("%d%d%d", &n, &m, &k);
for(i = 1; i <= n; i++)
scanf("%d", &arr[i]);
mem[0] = 0;
for(i = 1; i <= n; i++)
mem[i] = 1e14;
for(i = 1; i <= n; i++)
{
int mx = arr[i];
int mn = arr[i];
for(j = i; j > i - m && j >= 1; j--)
{
mx = max(arr[j], mx);
mn = min(arr[j], mn);
long long r = k + 1LL * (i - j + 1) * (mx - mn) + mem[j - 1];
mem[i] = min(r, mem[i]);
}
}
printf("%lld\n", mem[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... |