LIS

wikipedia
Description:

8
5
1
6
8
2
4
5
10


5


Code:

#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn=50050;
const int INF=0x3f3f3f3f;
int dp[maxn],a[maxn];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
fill(dp,dp+n,INF);
for(int i=0;i<n;i++)
{
*lower_bound(dp,dp+n,a[i])=a[i];
}
cout<<lower_bound(dp,dp+n,INF)-dp<<endl;
}


The main problem solving idea is

So we can use a convenient function,such aslower_bound.
Click to know more about lower_bound
Honestly, I don’t know what this has to do with DP, but it doesn’t matter, I will always know it later.