最少拦截系统(LIS)

题目:最少拦截系统 题解:LIS问题,求最长升序子序列。 #includeusing namespace std;typedef long long l

题目:最少拦截系统

题解:LIS问题,求最长升序子序列。

#include
using namespace std;
typedef long long ll;
const int N = 7e6+10;
const int inf = 0x7FFFFFFF;int f[N];
int ans = 0;void solve(int x){if(ans == 0 || x > f[ans-1]) {f[ans++] = x;return;}int k = lower_bound(f,f+ans,x)-f;f[k] = x;
}
int main(){int x,n;while(~scanf("%d",&n)){memset(f,0,sizeof f);ans = 0;while(n--){scanf("%d",&x);solve(x);}cout<