#C11414. Taco Expense Calculator

    ID: 40728 Type: Default 1000ms 256MiB

Taco Expense Calculator

Taco Expense Calculator

You are given a list of transactions. Each transaction is represented by a line that contains a date, a category, and an amount, separated by spaces. Your task is to calculate the total expenses for each category. For each category, sum the amounts from all transactions that belong to that category.

The calculation can be represented by the formula: $$Total_{\text{category}} = \sum_{i=1}^{n} a_i$$, where \(a_i\) are the amounts for the corresponding category.

Finally, output each category and its total expense in the order of their first appearance in the input. The amount must be formatted to two decimal places.

inputFormat

The first line contains an integer n representing the number of transactions. Each of the next n lines contains a transaction in the following format:

DD-MM-YYYY Category Amount

For example:

01-08-2021 Groceries 50.75

outputFormat

For each category, print a line containing the category followed by a space and the total expense for that category formatted to two decimal places. The categories should be printed in the order of their first occurrence in the input.

For example:

Groceries 81.65
Entertainment 40.20
Bills 100.00
## sample
5
01-08-2021 Groceries 50.75
01-08-2021 Entertainment 15.20
02-08-2021 Groceries 30.90
03-08-2021 Bills 100.00
03-08-2021 Entertainment 25.00
Groceries 81.65

Entertainment 40.20 Bills 100.00

</p>