tylerlong @ 2024-07-06 14:42:15
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int n,a[5005],dp[5005],sum=0;
int main() {
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
dp[1]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=i-1;j++){
if(a[i]>a[j])dp[i]=max(dp[i],dp[j]+1);
}
sum=max(sum,dp[i]);
}
cout<<sum<<endl;
return 0;
}
by Ivan422 @ 2024-07-06 14:51:32
就是呢
求关注谢谢喵
// test discuss
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int n,a[5005],dp[5005],sum=0;
int main() {
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
dp[i]=1;
for(int j=1;j<=i-1;j++){
if(a[i]>a[j])dp[i]=max(dp[i],dp[j]+1);
}
sum=max(sum,dp[i]);
}
cout<<sum<<endl;
return 0;
}
by tylerlong @ 2024-07-06 14:57:23
已关注,谢谢大佬!
by tylerlong @ 2024-07-06 14:57:36
本人已AC,此帖结