value = int(input()) inp = input().split() i = 1 answ = 0 sum1 = 0 sum2 = 0 while i < value: if inp[i] < inp[i-1]: if i%2 == 0: sum1 += 1 else: if inp[i] > inp[i-1]: if i%2 == 0: sum2 += 1 else: sum1 += 1 sum2 += 1 i += 1 i += 1 print(min(sum1, sum2))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | value = int(input()) inp = input().split() i = 1 answ = 0 sum1 = 0 sum2 = 0 while i < value: if inp[i] < inp[i-1]: if i%2 == 0: sum1 += 1 else: if inp[i] > inp[i-1]: if i%2 == 0: sum2 += 1 else: sum1 += 1 sum2 += 1 i += 1 i += 1 print(min(sum1, sum2)) |