#K151. Bank Transaction Simulation

    ID: 24281 Type: Default 1000ms 256MiB

Bank Transaction Simulation

Bank Transaction Simulation

This problem simulates a simple bank transaction system. In this system, each customer has an account starting with a balance of 0. You are given a series of transactions in the order they occur. The transactions can be one of the following commands:

  • deposit <name> <amount>: The customer identified by name deposits the specified amount into their account.
  • withdraw <name> <amount>: The customer identified by name attempts to withdraw the specified amount from their account. The withdrawal is only successful if the customer's balance satisfies \( \text{balance} \geq \text{amount} \) otherwise the transaction is ignored.
  • balance <name>: The current balance for the customer identified by name is output. If the account does not exist, it is assumed that the balance is 0.

The task is to process all transactions and output the result of each balance command.

inputFormat

The input is given via stdin in the following format:

  1. The first line contains an integer T, representing the total number of transactions.
  2. Each of the following T lines contains a transaction command. Each command is one of the following formats:
    • deposit <name> <amount>
    • withdraw <name> <amount>
    • balance <name>

outputFormat

The output should be printed to stdout. For every balance command processed, output a line in the following format:

<name> <balance> where balance is the current balance of the customer.

## sample
7
deposit Alice 200
deposit Bob 150
withdraw Alice 100
withdraw Bob 200
balance Alice
balance Bob
balance Charlie
Alice 100

Bob 150 Charlie 0

</p>