# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28387 | laaS (#68) | Wine Tasting (FXCUP2_wine) | C++14 | 0 ms | 9052 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<iostream>
#include<algorithm>
using namespace std;
long long int d[2][300000];
long long int arr[300000];
int main()
{
int n, k;
cin >> n >> k;
bool ind = false;
for (int i = 0; i < n; i++)
{
cin >> d[ind][i];
arr[i] = d[ind][i];
}
long long int temp = 0;
for (int i = 1; i < k; i++)
{
ind = !ind;
for (int j = i; j < n; j++)
{
d[ind][j] = 0;
for (int k = i - 1; k < j; k++)
{
temp = d[!ind][k];
if (arr[k] < arr[j])
temp += arr[j] - arr[k];
d[ind][j] = max(d[ind][j], temp);
}
}
}
temp = d[ind][k - 1];
for (int i = k; i < n; i++)
temp = max(temp, d[ind][i]);
cout << temp;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |