CF730J Bottles

Description

Nick has $ n $ bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda $ a_{i} $ and bottle volume $ b_{i} $ ( $ a_{i}

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first example Nick can pour soda from the first bottle to the second bottle. It will take 3 seconds. After it the second bottle will contain $ 3+3=6 $ units of soda. Then he can pour soda from the fourth bottle to the second bottle and to the third bottle: one unit to the second and two units to the third. It will take $ 1+2=3 $ seconds. So, all the soda will be in two bottles and he will spend $ 3+3=6 $ seconds to do it.