Description
Input
White spaces can occur freely in the input. The input data are correct and terminate with an end of file.
Output
For each set of data the program prints the result to the standard output from the beginning of a line.
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;
}