- 最长上升子序列 II
#include<iostream>
using namespace std;
int main()
{int n;int w[100001],v[100001];cin>>n;for (int i=0;i<n;i++) cin>>w[i];int len = 0;v[0] = -2e9;for (int i=0;i<n;i++){int l = 0,r = len;while (l<r){int mid = l+r+1>>1;if (v[mid]<w[i]) l = mid;//如果小于这个长度的最小值,那么答案就在左边else r = mid-1;//反之亦反}len = max(len,r+1);//最大长度v[r+1] = w[i];}cout<<len;return 0;
}