题解 | #合唱队#
合唱队
https://www.nowcoder.com/practice/6d9d69e3898f45169a441632b325c7b4
n = int(input())
s = list(map(int,input().split()))
dp1 = [1]*n
for i in range(n):
for j in range(i):
if s[i]>s[j]:
dp1[i]=max(dp1[i],dp1[j]+1)
dp2 = [1]*n
for i in range(n-1,-1,-1):
for j in range(n-1,i,-1):
if s[i]>s[j]:
dp2[i]=max(dp2[i],dp2[j]+1)
m = 0
for i in range(n):
if dp1[i]+dp2[i]-1>m:
m = dp1[i]+dp2[i]-1
print(n-m)