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:
parent
a4c6e79f99
commit
aac871e5ec
23
AcWing/895/895.cpp
Normal file
23
AcWing/895/895.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user