n,tones,counter = int(input()),input().split(),0 tab1,tab2 = [int(tones[i]) for i in range(n) if i%2==0], [int(tones[i]) for i in range(n) if i%2!=0] if tab1[0]>tab2[0]: for i in range(int(n/2)): if tab1[i]<=tab2[i] or tab2[i]>=tab1[i+1]: counter+=1 else: for i in range(int(n/2)): if tab1[i]>=tab2[i] or tab2[i]<=tab1[i+1]: counter+=1 print(counter)
1 2 3 4 5 6 7 8 9 10 11 | n,tones,counter = int(input()),input().split(),0 tab1,tab2 = [int(tones[i]) for i in range(n) if i%2==0], [int(tones[i]) for i in range(n) if i%2!=0] if tab1[0]>tab2[0]: for i in range(int(n/2)): if tab1[i]<=tab2[i] or tab2[i]>=tab1[i+1]: counter+=1 else: for i in range(int(n/2)): if tab1[i]>=tab2[i] or tab2[i]<=tab1[i+1]: counter+=1 print(counter) |