标签:
Description
Input
Output
Sample Input
6 5 2 1 4 5 3 3 1 1 1 4 4 3 2 1
Sample Output
3 1 1
Hint
#include <iostream>
#include<stdio.h>
using namespace std;
int a[150000],b[150000],t;
void dog(int z)
{
int x,y,mid;
x=1;
y=t;
while(x<=y)
{
mid=(x+y)/2;
if (b[mid]==z) return ;
else
if (b[mid]>z) y=mid-1;
else
x=mid+1;
}
if (x==t+1)
{
t++;
b[t]=z;
}
else
b[x]=z;
}
int main() {
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
t=1;
b[1]=a[1];
for(i=2;i<=n;i++)
{
dog(a[i]);
}
printf("%d\n",t);
}
return 0;
}
2015 HUAS Summer Trainning #5~E
标签:
原文地址:http://www.cnblogs.com/chenchunhui/p/4722462.html