#C5291. Categorize Expense Transactions

    ID: 48924 Type: Default 1000ms 256MiB

Categorize Expense Transactions

Categorize Expense Transactions

You are given a list of expense transactions in the form (\texttt{amount_description}), where (amount) is a floating-point number and (description) is a string representing the expense details. Your task is to categorize each transaction into one of the following four categories:

(\textbf{Food}): if the description contains any of the keywords: dinner, lunch, breakfast, snack, grocery (\textbf{Transport}): if the description contains any of the keywords: bus, taxi, train, fuel (\textbf{Entertainment}): if the description contains any of the keywords: movies, concert, game

If none of these keywords are found, the transaction is categorized as (\textbf{Misc}). Calculate the total expense for each category.

(\textbf{Input Format:}) The first line contains an integer (N) representing the number of expense transactions. The following (N) lines each contain a transaction in the format (\texttt{amount_description}).

(\textbf{Output Format:}) Output four lines. Each line should contain a category name followed by the total amount spent in that category, formatted to two decimal places. The categories must be output in the following order: Food, Transport, Entertainment, Misc.

inputFormat

The input starts with an integer (N) ((1 \leq N \leq 10^5)), representing the total number of expense records. Each of the next (N) lines contains a string in the format (\texttt{amount_description}), where (amount) is a floating-point number and (description) is a non-empty string.

outputFormat

Print exactly four lines. Each line must display a category name and the corresponding sum of expenses in that category, formatted to two decimal places. The output order should be:

Food Transport Entertainment Misc## sample

8
15.50_dinner
2.75_bus
8.20_grocery
10_movies
5.00_snack
12.30_train
4.50_taxi
3.00_coffee
Food 28.70

Transport 19.55 Entertainment 10.00 Misc 3.00

</p>