NYOJ 214 单调递增子序列(二)

#include<stdio.h>
#include<algorithm>
using namespace std;
const int Max=100100;
int num[Max];
int top=0;
int main()
{
 int n;
 while(~scanf("%d",&n))
 {
  scanf("%d",&num[0]);
  top=1;
  for(int i=1;i!=n;i++)
  {
   scanf("%d",&num[i]);
   int *p=lower_bound(num,num+top,num[i]);
   if(p-num==top) ++top;
   *p=num[i];  
  }
  printf("%d\n",top);
 }
} //最优代码,留个模板。。。

posted @ 2015-11-10 19:16  小松鼠。  阅读(95)  评论(0编辑  收藏  举报