Loading...
Loading...
Loading...
A team receives N tasks, each with a number of hours. Split the tasks between two people so that the difference between the two totals is as small as possible. Print that smallest difference.
Example
Input
4 3 9 7 3
Output
2
3 + 9 = 12 and 7 + 3 = 10, difference 2.
Try the problem first. Open one hint at a time.
If one person gets total s, the other gets total - s. The difference is total - 2s.
Find which totals up to half can be made, and take the largest of them.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor