Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
44441 lmz120809 最长上升子序列 C++ Accepted 0 MS 260 KB 349 2024-03-30 12:51:49

Tests(1/1):


#include<iostream> using namespace std; int a[1005],dp[1005]; int main() { int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } int maxn=-1; for(int i=1;i<=n;i++){ dp[i]=1; for(int j=1;j<i;j++){ if(a[j]<a[i]&&dp[j]+1>dp[i]){ dp[i]=dp[j]+1; } maxn=max(maxn,dp[i]); } } cout<<maxn<<endl; return 0; }


Judgement Protocol: