#K80977. Bank Account Management
Bank Account Management
Bank Account Management
You are required to implement a bank account management system that processes a series of commands. There are \(M\) bank accounts (numbered from 1 to \(M\)), each initially having a balance of 0. The system supports two types of commands:
- Type 1: Update the balance of an account. The command is provided in the form \(1\ a\ d\), meaning that \(d\) (which can be negative for withdrawals) should be added to account \(a\).
- Type 2: Retrieve the current balance of an account. The command is given as \(2\ a\), where you need to output the current balance of account \(a\).
Process all commands in the given order and output the resulting balances for each retrieval command.
inputFormat
The first line of input contains two integers (M) and (Q), representing the number of bank accounts and the number of commands, respectively. The next (Q) lines each represent a command. For a command of type 1, the line contains three integers: 1, a, and d, meaning update account (a) by (d). For a command of type 2, the line contains two integers: 2 and a, indicating that you should output the current balance of account (a).
outputFormat
For each command of type 2, output the corresponding account balance on a new line in the order the commands appear.## sample
3 5
1 1 500
1 2 300
2 1
1 1 -200
2 1
500
300
</p>