百练2757

可调用库函数:max_element(v.begin(),v.end()); 返回值为 指针

#include <iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    int N,L[1010],dp[1010];
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> L[i];
    }
    memset(dp,0,sizeof(dp));
    dp[1] = 1;
    L[0] = -1;
    for(int  i = 2; i <= N;i++){
        for(int j = 0; j < i; j++){
            if(L[j] < L[i])   dp[i] = max(dp[i],dp[j] + 1);
        }
    }
    int maxn = 0;
    for(int i = 1; i <= N; i++){
        maxn = max(maxn,dp[i]);
    }
    cout << maxn;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ehdhg13455/article/details/81427662