daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 16th, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. size = int(input())
  2. seats = [int(elem) for elem in input().split(' ')]
  3. seats = sorted(seats)
  4. order = [0] * size
  5. order[0] = 99999
  6. order[1] = seats[1] - seats[0]
  7. for i in range(2, len(seats)):
  8.     order[i] = min(order[i-1]+seats[i]-seats[i-1], order[i-2]+seats[i]-seats[i-1])
  9. print(order[size-1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top