mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:48:48 +00:00
1017. 怪盗基德的滑翔翼
https://www.acwing.com/problem/content/submission/code_detail/8791523/
This commit is contained in:
parent
3952c7b359
commit
2611a0d1e0
34
AcWing/1017/1017.cpp
Normal file
34
AcWing/1017/1017.cpp
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user