You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
555 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n;
int a[N], f[N];
int res;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
1 year ago
f[i] = 1; // 一个以i结尾的序列最少可以是i自己长度是1
2 years ago
for (int j = 1; j < i; j++)
1 year ago
if (a[i] > a[j]) // i可以接在j后面
f[i] = max(f[i], f[j] + 1); // 借力于j
2 years ago
res = max(res, f[i]);
}
printf("%d", res);
return 0;
}