0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:45:24 +00:00

1281. 最长上升子序列

http://ybt.ssoier.cn:8088/statusx.php?runidx=15570483
This commit is contained in:
Baoshuo Ren 2022-04-02 19:01:17 +08:00
parent 7acf5b0d8d
commit 89ef0aac23
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

30
ybt/1281/1281.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1005;
int n, a[N], f[N], ans;
int main() {
std::ios::sync_with_stdio(false);
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[i] > a[j]) f[i] = std::max(f[i], f[j] + 1);
}
ans = std::max(ans, f[i]);
}
cout << ans << endl;
return 0;
}