Files
python/TangDou/AcWing/LIS/895.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

24 lines
555 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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++) {
f[i] = 1; // 一个以i结尾的序列,最少可以是i自己,长度是1
for (int j = 1; j < i; j++)
if (a[i] > a[j]) // i可以接在j后面
f[i] = max(f[i], f[j] + 1); // 借力于j
res = max(res, f[i]);
}
printf("%d", res);
return 0;
}