laugh_taleCF @ 2024-10-22 17:03:25
#include <iostream>
using namespace std;
const int N=5010;
int f[N],a[N];
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++)
{
f[i]=1;
for(int j=0;j<i;j++)
{
if(a[j]<a[i]) f[i]=max(f[i],f[j]+1);
}
}
int ans;
for(int i=0;i<n;i++) ans=max(ans,f[i]);
cout<<ans<<endl;
return 0;
}
by laugh_taleCF @ 2024-10-22 17:05:07
@laugh_taleCF 刚刚找到了,int ans;有问题,在main函数里面定义要int ans=0;
by zhao_sd @ 2024-10-22 17:25:21
@laugh_taleCF 所以是不需要帮助了是吗
by laugh_taleCF @ 2024-10-23 15:41:40
@zhao_sd 对的对的,已经过了,谢谢~