Advertisement
Guest User

Untitled

a guest
May 21st, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. N = input()
  2. m = int(N[-1])
  3. N = int(N[0])
  4. blocks = list(map(int, input().split(" ")))
  5.  
  6. if min(blocks) + max(blocks) > N:
  7.     print(0)
  8.  
  9. elif sum(blocks *2) < N:
  10.     print(-1)
  11.  
  12. else:
  13.     res = []
  14.     for x in blocks:
  15.         if N-x in blocks:
  16.             res.append(x)
  17.             res.append(N-x)
  18.         elif N - x*2 in blocks:
  19.             res.append(x)
  20.             res.append(x)
  21.             res.append(N-2*x)
  22.     print(len(res))
  23.     print(" ".join(map(str, res)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement