40tps求助TVT
查看原帖
40tps求助TVT
1243618
Jokersheng楼主2025/1/12 11:59
#include <bits/stdc++.h>
using namespace std;

const int N=5050;

int n,a[N],s[N],maxx;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	s[n]=1;
	for(int i=n-1;i>=1;i--){
		maxx=INT_MIN;
		for(int j=i+1;j<=n;j++){
			if(maxx<s[j]&&a[i]<a[j]){
				maxx=s[j];
			}
		}
		s[i]=max(0,maxx+1);
	}
	maxx=INT_MIN;
	for(int i=1;i<=n;i++){
		maxx=max(maxx,s[i]);
	}
	cout<<maxx;
	return 0;
}

2025/1/12 11:59
加载中...