Codeup-100000627-《算法笔记》
作者:互联网
前言:
21考研,正在啃《算法笔记》,不论能否进复试记录一下准备路上写下的垃圾代码。
解答:
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1000 + 10;
int dp[maxn];
int main()
{
int n;
int a[maxn];
while (cin >> n) {
int max = 0;
for (int i = 0; i < n; i++)
dp[i] = 1;
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++)
if (dp[i] <= dp[j] && a[i] > a[j])
dp[i] = dp[j] + 1;
if (max < dp[i])
max = dp[i];
}
cout << max << endl;
}
return 0;
}
标签:100000627,int,max,++,算法,maxn,Codeup,include,dp 来源: https://blog.csdn.net/weixin_44897291/article/details/113789696