虽然第一段代码全点通过还是觉得不太对。感觉第二段代码才对。
0 1 0 2 1 2 0 0 2 0 1 1 1 2
5
第一段:
n=int(input())
ls=list(map(int,input().split()))
count=0
for i in range(1,len(ls)-1):
if ls[i-1]>=ls[i] and ls[i]<ls[i+1]:
count+=1
print(count)
输入0 1 0 2 1 2 0 0 2 0 1 1 1 2
5
就出错
第二段
n=int(input())
ls=list(map(int,input().split()))
for j in range(len(ls)-2):
if ls[j]==ls[j+1]:
ls.pop(j)
count=0
for i in range(1,len(ls)-1):
if ls[i-1]>ls[i] and ls[i]<ls[i+1]:
count+=1
print(count)