#P8298. [COCI 2012/2013 #2] POPUST
[COCI 2012/2013 #2] POPUST
Background
The score for this problem follows the original COCI settings, with a full score of .
Problem Description
Mirko is as hungry as a bear and finds a local restaurant. This restaurant offers meals and has an interesting pricing policy: each meal has two specified prices, and . The first dish Mirko orders only costs money, and all other dishes cost money.
Mirko cannot decide how many dishes to order. To make the decision easier, he asks you for help. For any , find the minimum amount of money he needs to pay to order dishes. Mirko does not care which specific meals he orders, nor the order in which he orders them, but he will not order two identical dishes.
Input Format
The first line contains a positive integer , which is the number of dishes.
The next lines each contain two positive integers , as described in the statement.
Output Format
Output lines. The -th line should be the minimum amount of money needed to order distinct dishes.
3
10 5
9 3
10 5
9
13
18
2
100 1
1 100
1
2
5
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000 1000000000
1000000000
2000000000
3000000000
4000000000
5000000000
Hint
Explanation for Sample #1
-
: Mirko starts by ordering the -nd dish, with a total cost of .
-
: Mirko starts by ordering the -st dish, then orders the -nd dish, with a total cost of .
-
: Mirko starts by ordering the -st dish, then orders dishes , with a total cost of .
Translated by ChatGPT 5