CodePSU 2019 - Advanced


2019-03-24 09:15 AKDT

CodePSU 2019 - Advanced


2019-03-24 13:15 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -671 days 3:51:03

Time elapsed


Time remaining


Problem D
Grocery Shopping

It’s time to go grocery shopping, but there’s no need to fear because you’ve prepared for this. You’ve been making a grocery list all week. However, your list is all out of whack. You’ve just been adding items as you think of them, so there is no order to the list at all and some of the items that you need are on there multiple times. In order to shop most efficiently, you need to organize your list by order of increasing price. If multiple items have the same price, then sort them alphabetically. For all items that appear on the list more than once, keep track how many of that item you need. Once the list is in order, you’ll be able to spend plenty of money that you don’t have on groceries!


The first line of input is a number, $n$ ($1 \leq n \leq 10\, 000$), representing the number of items on your grocery list. Then, the following $n$ lines of input are formatted as $x$ $y$. Where $x$ is a string representing the name of the item and $y$ ($0.01 \leq y \leq 1\, 000.00$) is a real value with up to two decimal places representing its price.


Output the names of the items and the number of each item on your grocery list sorted by price.

Sample Input 1 Sample Output 1
Orange 1.25
Banana 2.50
Orange 1.25
Grape 0.10
Grape 1
Orange 2
Banana 1