求数组的最大递增子序列/最大递减子序列
/// 求数组的最大递增子序列/最大递减子序列
#include <bits/stdc++.h>
using namespace std;
int LIS(vector<int> vec)
{
int res = 0;
int sz = vec.size();
vector<int> dp(sz +1, 0);
dp[0] = 1;
for(int i = 1; i < sz; i++)
{
for(int j = 0; j < i; j++)
{
if(vec[j] < vec[i]){
if(dp[i] < dp[j] + 1) {
dp[i] = dp[j] + 1;
}
}
}
res = max(res, dp[i]);
}
return res;
}
int main()
{
vector<int> array= {1,4,5,6,2,3,8,9,10,11,12,12,1};
int res = LIS(array);
cout << res <<endl;
return 0;
}