0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 17:32:00 +00:00

1286. 怪盗基德的滑翔翼

http://ybt.ssoier.cn:8088/statusx.php?runidx=15575223
This commit is contained in:
Baoshuo Ren 2022-04-02 21:50:01 +08:00
parent 2b4c824a0e
commit 1dfbb8ac7e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

47
ybt/1286/1286.cpp Normal file
View File

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