跳到正文

个人记录

LIS

jiangyunuo约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年7月22日
收录
2026年7月8日
更新
2026年10月25日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin>>n;
    int a[n+1],b[n+1],tot=0,f[n+1];
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    }
    b[++tot]=a[1];
    f[1]=1;
    for(int i=2;i<=n;i++){
    	if(a[i]>b[tot])b[++tot]=a[i];
    	else{
			x=lower_bound(b+1,b+tot+1,a[i])-b;
			b[x]=a[i];
    	}
    }
    cout<<tot<<endl;
	return 0;
}
原文