0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:38:48 +00:00

895. 最长上升子序列

https://www.acwing.com/problem/content/submission/code_detail/8843660/
This commit is contained in:
Baoshuo Ren 2021-11-15 15:30:25 +08:00 committed by Baoshuo Ren
parent a4c6e79f99
commit aac871e5ec
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

23
AcWing/895/895.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <bits/stdc++.h>
using namespace std;
int n, a[1005], f[1005], ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
f[i] = 1;
for (int j = 1; j < i; j++) {
if (a[j] < a[i]) {
f[i] = max(f[i], f[j] + 1);
}
}
ans = max(ans, f[i]);
}
cout << ans << endl;
return 0;
}