Advertisement
PlotnikovPhilipp

Untitled

Oct 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. amountOfStones = int(input())
  3. stones = [int(i) for i in input().split()]
  4. stones.sort(reverse=True)
  5. first = [stones[0]]
  6. second = []
  7. i = 1
  8. while i < len(stones):
  9.     if sum(first) > sum(second):
  10.         second.append(stones[i])
  11.     else:
  12.         first.append(stones[i])
  13.     i += 1
  14. print(abs(sum(first) - sum(second)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement