【样例解释】
最长不下降子序列为3,6,7
有两种做法
一种是O(n^2)
The other one is O(log n)
We always use the second one
Because is faster than the first one
But how to do it?
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s[100000];
int ans,n;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
int sum;
scanf("%d",&sum);
if(sum>s[ans])
s[++ans]=sum;
else
{
int p=(lower_bound(s+1,s+ans+1,sum)-s);
s[p]=sum;
}
}
printf("%d",ans);
return 0;
}