题目意思让你找一个最长的升序子序列
#include"bits/stdc++.h" #define ll long long #define pi pair#define inf 0x3f3f3f3f #define _for(i,a,b) for(int i=a;i<=b;i++) #define for_(i,a,b) for(int i=a;i=b;i--) #define fr_(i,a,b) for(int i=a;i>b;i--) #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; const int N = 1e5+5; const ll mod = 1e9+7; const double lp=1.000000011; map mp; int n,x; int a[N],b[N],c[N]; void solve(){ cin >> n; _for(i,1,n) cin >> a[i]; _for(i,1,n) b[i]=inf; _for(i,1,n){ int k = lower_bound(b+1,b+1+n,a[i])-b; c[i]=k; b[k]=a[i]; } int ans = -inf; _for(i,1,n){ ans = max(ans,c[i]); } cout << ans << endl; } int main() { IOS; solve(); return 0; }



