http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1134&judgeId=529543 
    <nobr aria-hidden="true">    dp[len]   </nobr>    <math xmlns="http://www.w3.org/1998/Math/MathML">     <mi>      d     </mi>     <mi>      p     </mi>     <mo stretchy="false">      [     </mo>     <mi>      l     </mi>     <mi>      e     </mi>     <mi>      n     </mi>     <mo stretchy="false">      ]     </mo>    </math>表示长度为l   <nobr aria-hidden="true">    en   </nobr>    <math xmlns="http://www.w3.org/1998/Math/MathML">     <mi>      e     </mi>     <mi>      n     </mi>    </math>的序列中,最后一个数的多少
#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;
    }
}

 京公网安备 11010502036488号
京公网安备 11010502036488号