
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Greedily sell the most expensive ball.
There is some value k where all balls of value > k are sold, and some, (maybe 0) of balls of value k are sold.
Use binary search to find this value k, and use maths to find the total sum.