水题
#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int main(int argc, char const *argv[])
{
int n;
cin >> n;
int high[maxn];
for(int i = 1; i <= n; i++) cin >> high[i];
int f[maxn] = {0};
int g[maxn] = {0};
int anss = maxn;
for(int i = 1; i <= n; i++) {
int ans;
f[1] = 1; g[n] = 1;
for(int j = 2; j <= i; j++) {ans = 0;
for(int k = 1; k < j; k++) {
if(high[k] < high[j]) ans = max(ans, f[k]);
}
f[j] = ans + 1;
}
for(int j = n-1; j >= i; j--) {
ans = 0;
for(int k = n; k > j; k--) {
if(high[k] < high[j]) ans = max(ans, g[k]);
}
g[j] = ans + 1;
}
int a = f[i], b = g[i];
anss = min(anss, n-a-b+1);
}
cout << anss;
return 0;
}