QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 256 MB 満点: 100

#22751. Bank Balance

統計

Alice, Betsy, Corinne, and Debra have opened bank accounts. The bank has kept a central ledger of their deposits (money into the bank) and withdrawals (money out of the bank). They are good financial citizens and never withdraw more money than they have.

Given the ledger (see format below), print the amount of money each has in the bank after the ledger's transactions are completed. The initial balance for each is, of course, 0. All numbers fit into 32 bit integers.

Input

  • Line 1: A single integer $N$, the number of transactions
  • Lines $2$ through $N+1$: Each line contains a single transaction with two fields. The first field is the name of the person performing the transaction. The second field is a number: if positive, the number is a deposit; if negative, the number is a withdrawal.

Output

  • Lines $1..4$: Each line tells the name and balance of one of the depositors. The depositors are listed in alphabetical order.

Examples

Input 1

6
Alice +100
Corinne +100
Betsy +200
Alice -10
Debra +10
Betsy -100

Output 1

Alice 90
Betsy 100
Corinne 100
Debra 10

Input Details

Alice deposits 100; so does Corrinne. Betsy deposits 200. Alice takes out 10; Debra puts in 10. Betsy takes out 100. The input never contains names other than 'Alice', 'Betsy', 'Corinne', and 'Debra'.

Problem credits: Rob Kolstad, 2004

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.