Submission #28344

#TimeUsernameProblemLanguageResultExecution timeMemory
28344laaS (#68)Wine Tasting (FXCUP2_wine)C++14
0 / 1
0 ms2020 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n, k; cin >> n >> k; vector<vector<long long int> > arr(k); arr[0].resize(n); for (int i = 0; i < n; i++) cin >> arr[0][i]; long long 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 timeMemoryGrader output
Fetching results...