COCI '12 Contest 2 #4 Popust
View as PDFMirko is hungry as a bear, scratch that, programmer and has stumbled upon a local restaurant. The restaurant offers  meals and has an interesting pricing policy: each meal 
 has two assigned prices, 
 and 
. Mirko pays 
 only for the first ordered meal, while 
 prices apply for all other meals.
Mirko can't decide how many meals to order. In order to make his decision easier, he has asked you to compute, for each  between 
 and 
 (inclusive), the minimum total price for 
 ordered meals. Mirko doesn't care which particular meals he orders or in which order he orders them, however he won't order the same meal twice. Order, order, order.
Input Specification
The first line of input contains the positive integer  
, the number of different meals offered by the restaurant.
Each of the following  lines contains two positive integers, 
 and 
 
, the prices for meal 
 as described above.
Output Specification
Output must consist of  lines, where line 
 contains the minimum price for ordering exactly 
 different meals.
Sample Input 1
3
10 5
9 3
10 5
Sample Output 1
9
13
18
Explanation for Sample Output 1
: Mirko pays 
 for the starting meal 
.
: Mirko pays 
 for the starting meal 
, then 
 for meal 
.
: Mirko pays 
 for the starting meal 
, then 
 for meal 
, and finally 
 for meal 
.
Sample Input 2
2
100 1
1 100
Sample Output 2
1
2
Sample Input 3
5
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
Sample Output 3
1000000000
2000000000
3000000000
4000000000
5000000000
Comments