0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 14:36:27 +00:00

1017. 怪盗基德的滑翔翼

https://www.acwing.com/problem/content/submission/code_detail/8791523/
This commit is contained in:
Baoshuo Ren 2021-11-12 21:44:08 +08:00 committed by Baoshuo Ren
parent 3952c7b359
commit 2611a0d1e0
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

34
AcWing/1017/1017.cpp Normal file
View File

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