Submission #28334

# Submission time Handle Problem Language Result Execution time Memory
28334 2017-07-16T04:48:48 Z laaS(#1111, fpdjsns) Wine Tasting (FXCUP2_wine) C++14
0 / 1
0 ms 2020 KB
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<vector<int>> arr(k);
	arr[0].resize(n);
	for (int i = 0; i < n; i++)
		cin >> arr[0][i];
	int temp;
	for (int i = 1; i < k; i++)
	{
		arr[i].resize(n, 0);
		for (int j = i; j < n; j++)
		{
			for (int k = i - 1; k < j; k++)
			{
				temp = arr[i - 1][k];
				if (arr[0][k] < arr[0][j])
					temp += arr[0][j] - arr[0][k];
				arr[i][j] = max(arr[i][j], temp);
			}
		}
	}
	temp = arr[k - 1][0];
	for (int i = 1; i < n; i++)
		temp = max(temp, arr[k - 1][i]);
	cout << temp;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Incorrect 0 ms 2020 KB Output isn't correct
4 Halted 0 ms 0 KB -