Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. R = -1
  3. maxch = 0
  4. maxnech = 0
  5. minch = 10001
  6. minnech = 10001
  7.  
  8. for i in range(n):
  9.     x = int(input())
  10.     if x > maxch and x % 2 == 0:
  11.         maxch = x
  12.     if x > maxnech and x % 2 != 0:
  13.         maxnech = x
  14.     if x < minch and x % 2 == 0:
  15.         minch = x
  16.     if x < minnech and x % 2 != 0:
  17.         minnech = x
  18. if maxch != 0 and maxnech != 0 and minch != 10001 and minnech != 10001:
  19.     if maxch - minnech > maxnech - minnech:
  20.         R = maxch - minnech
  21.     else:
  22.         R = maxnech - minnech
  23. print(R)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement