题解 | #合唱队#
合唱队
https://www.nowcoder.com/practice/6d9d69e3898f45169a441632b325c7b4
N = int(input()) ls = list(map(int,input().split())) ls1 = [1] * len(ls) ls2 = [1] * len(ls) # 合唱队遍历的一定是位置 #左 for i in range(len(ls)-1): for j in range(i+1): if ls[i] > ls[j] and ls1[i] < ls1[j]+1: ls1[i] = ls1[j]+1 # 右 for i in range(len(ls)-1,-1,-1): for k in range(len(ls)-1,i-1,-1): if ls[i] > ls[k] and ls2[i] < ls2[k]+1: ls2[i] = ls2[k]+1 p = 0 for i in range(N): if ls1[i]+ls2[i]-1 > p: p = ls1[i]+ls2[i]-1 print(N-p)