#t121. 小杨的智慧购物
小杨的智慧购物
Xiaoyang's Smart Shopping
Problem Description
Xiaoyang's class is holding an eco-friendly handcraft exhibition, and the teacher asks Xiaoyang to go to the stationery store to buy different kinds of stationery (for example: pencils, erasers, rulers, etc.).
The store has items in total, and each item has a type id (from to ) and a price.
Xiaoyang's budget is limited, so he came up with a clever idea: for each kind of stationery, he only buys the cheapest one (if several items of the same kind share the lowest price, he buys only one of them). Please help Xiaoyang compute how much he needs to spend in total to buy all kinds of stationery.
Input Format
The first line contains two positive integers , the number of kinds of stationery and the total number of items.
The following lines each contain two positive integers and , representing the type id and the price of the -th item. The data guarantees that each kind has at least one item available to buy.
Output Format
Output one line: the total price of the stationery purchased.
Sample Input
2 5
1 1
1 2
1 1
2 3
2 10
Sample Output
4
Sample Explanation
The item list is as follows:
- Item 1: type , price
- Item 2: type , price
- Item 3: type , price
- Item 4: type , price
- Item 5: type , price
Xiaoyang's selection process: for type , there are three items priced , the cheapest of which is ; for type , there are two items priced , the cheapest of which is .
Total price: Xiaoyang spends in total for these two kinds of stationery.
Constraints
For all test cases, , , .