ile=int(input()) plisz=input().split() ppo=0 dpo=0 plisz2=[] for i in range(len(plisz)): plisz[i]=int(plisz[i]) plisz2.append(plisz[i]) for i in range(1,len(plisz)): if plisz[i]<=plisz[i-1]: if i%2==0: ppo+=1 plisz[i]=100000000 if plisz[i]>=plisz[i-1]: if i%2==1: ppo+=1 plisz[i]=-1000000000000 for i in range(1,len(plisz)): if plisz[i]<=plisz[i-1]: if i%2==1: dpo+=1 plisz[i]=100000000 if plisz[i]>=plisz[i-1]: if i%2==0: dpo+=1 plisz[i]=-1000000000000 print(min(ppo,dpo))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ile=int(input()) plisz=input().split() ppo=0 dpo=0 plisz2=[] for i in range(len(plisz)): plisz[i]=int(plisz[i]) plisz2.append(plisz[i]) for i in range(1,len(plisz)): if plisz[i]<=plisz[i-1]: if i%2==0: ppo+=1 plisz[i]=100000000 if plisz[i]>=plisz[i-1]: if i%2==1: ppo+=1 plisz[i]=-1000000000000 for i in range(1,len(plisz)): if plisz[i]<=plisz[i-1]: if i%2==1: dpo+=1 plisz[i]=100000000 if plisz[i]>=plisz[i-1]: if i%2==0: dpo+=1 plisz[i]=-1000000000000 print(min(ppo,dpo)) |