problem
solution
codes
#include<iostream>
using namespace std;
int h[110],f[110],f2[110], ans;
int main(){
int n; cin>>n;
for(int i = 1; i <= n; i++)cin>>h[i];
for(int i = 1; i <= n; i++){
int t = 0;
for(int j = 1; j < i; j++)
if(h[j]<h[i] && f[j]>f[t])
t = j;
f[i] = max(f[i],f[t]+1);
}
for(int i = n; i >= 1; i--){
int t = 0;
for(int j = n; j > i; j--)
if(h[j]<h[i] && f2[j]>f2[t])
t = j;
f2[i] = max(f2[i],f2[t]+1);
ans = max(ans,f[i]+f2[i]-1);
}
cout<<n-ans<<"
";
return 0;
}