def main(): def check(go, last): c = 0 for number in numbers: if last * go >= number * go: c += 1 last = A * go else: last = number go *= -1 return c _ = int(input()) nums = input().split() numbers = [int(num) for num in nums] A = 10000000 print(min(check(1, -A), check(-1, A))) if __name__ == '__main__': main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | def main(): def check(go, last): c = 0 for number in numbers: if last * go >= number * go: c += 1 last = A * go else: last = number go *= -1 return c _ = int(input()) nums = input().split() numbers = [int(num) for num in nums] A = 10000000 print(min(check(1, -A), check(-1, A))) if __name__ == '__main__': main() |