i holds bags[i] sweets. All bags must be handed out to kids children. A bag cannot be opened, so it goes to one child as a whole. A child may end up with no bags.
The **imbalance** of a hand-out is the largest number of sweets any single child receives. Return the smallest possible imbalance.bags=[5, 9, 4, 6], kids=2 → 13
There are 24 sweets in total. One child gets the bags with 5 and 6, the other gets 9 and 4: that is 11 and 13. An even 12–12 split is impossible, so the answer is 13.
bags=[3, 3, 3, 20, 3], kids=3 → 20
The bag of 20 cannot be split, so someone gets at least 20. The other bags go easily to the other two children.
bags=[7, 2, 2, 3, 6, 4], kids=3 → 9
bags) ≤ 8bags[i] ≤ 10⁵kids ≤ len(bags)bags=[5, 9, 4, 6], kids=2
13
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.