#include<iostream>
using namespace std;
#include<cstdio>
int i,j,n,a[100001],b[100001],m,ans=0,left,k;
int find(int r,int x)
{
int m,left=0;
while(left<=r)
{
m=(left+r)/2;
if(x>b[m])left=m+1;
else if(x<b[m])r=m-1;
else {k=left;return m;}
}
k=left;
return left;
}
int main()
{
scanf("%d",&n);
for(i=n;i>0;i--)scanf("%d",&a[i]);
for(i=1;i<=n;i++)
{
j=1;k=ans;
while(j<=k){
m=(j+k)/2;
if(b[m]<=a[i])j=m+1;
else k=m-1;
}
if(j>ans)ans++;
b[j]=a[i];
}
printf("%d",ans);
return 0;
}
【9018p1407】拦截导弹(二分)
最新推荐文章于 2021-07-28 23:11:58 发布