40求调(AC互关)

B3637 最长上升子序列

lsd110504 @ 2024-10-12 16:20:44

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1],c[n+1];
    memset(c,0,sizeof(c));
    int ans=0,cmp=0;
    c[1]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        for(int j=i-1;j>=1;j--)
        {
            if(a[j]<a[i]&&c[j]>cmp){
                cmp=c[j];
                c[i]=c[j]+1;
                ans=max(ans,c[i]);
            }
            else

                continue;
        } 
        cmp=0;
    }
    cout<<ans;
    return 0;
} 

by lsd110504 @ 2024-10-12 16:52:45

关了哦@ccch1ennn


上一页 |