最长上升子序列
2018-06-21 本文已影响0人
见习炼丹师
//最大上升子序列
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
int N;
int a[1005];
int b[1005] = {1};
int main()
{
cin >> N;
for(int i = 0; i < N; ++i)
cin >> a[i];
for(int i = 1; i < N; ++i)
{
for(int j = 0; j < i; ++j)
{
if(a[j] < a[i])
{
b[i] = max(b[j]+1, b[i]);
}
}
}
int MaxIncrease = *max_element(b, b+N);
cout << MaxIncrease;
return 0;
}