http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1134&judgeId=529543
dp[len]
d
p
[
l
e
n
]
表示长度为l
en
e
n
的序列中,最后一个数的多少
#include"bits/stdc++.h"
using namespace std;
const int maxn=1e5+5;
int dp[maxn];
int main()
{
int N;
while(cin>>N)
{
memset(dp,-0x3f,sizeof(dp));
int len=1;
cin>>dp[1];
for(int i=1;i<N;i++)
{
int t;
cin>>t;
if(t>dp[len])dp[++len]=t;
else
{
int pos=upper_bound(dp+1,dp+1+len,t)-dp;
dp[pos]=t;
}
}
cout<<len<<endl;
}
}