n = int(input()) a = [int(i) for i in str(input()).split()] if a[0] <= a[1]: a.insert(0,1000001) if len(a)%2 == 0: a.append(1000001) n = 0 for i in range(1,len(a),2): if a[i] >= a[i-1] and a[i] >= a[i+1]: n+=1 a[i] = -1000001 if a[i] >= a[i-1]: n+=1 a[i-1] = 1000001 if a[i] >= a[i+1]: n+=1 a[i+1] = 1000001 print(n)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | n = int(input()) a = [int(i) for i in str(input()).split()] if a[0] <= a[1]: a.insert(0,1000001) if len(a)%2 == 0: a.append(1000001) n = 0 for i in range(1,len(a),2): if a[i] >= a[i-1] and a[i] >= a[i+1]: n+=1 a[i] = -1000001 if a[i] >= a[i-1]: n+=1 a[i-1] = 1000001 if a[i] >= a[i+1]: n+=1 a[i+1] = 1000001 print(n) |