0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 22:25:27 +00:00
OI-codes/AcWing/1017/1017.cpp

35 lines
802 B
C++

#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;
}