最少拦截系统
HDU - 1257
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define MAXN 40005
int arr[MAXN],ans[MAXN],len;
int main()
{
int T,p,i;
while(~scanf("%d",&p))
{
for(i=1; i<=p; ++i)
scanf("%d",&arr[i]);
ans[1] = arr[1];
len=1;
for(i=2; i<=p; ++i)
{
if(arr[i]>ans[len])
ans[++len]=arr[i];
else
{
int pos=lower_bound(ans+1,ans+len+1,arr[i])-ans;
ans[pos] = arr[i];
}
}
printf("%d\n",len);
}
return 0;
}