#K38602. Transaction Completion Verification
Transaction Completion Verification
Transaction Completion Verification
In this problem, you are given a series of transactions for two banks, Bank A and Bank B. Each transaction is represented by a type, an amount, and the bank identifier.
For Bank A, only deposits of amounts 5
and 10
are allowed, and withdrawals of 15
can only be made by combining one 5
and one 10
note. This can be expressed by the equation: $$15 = 5 + 10$$.
For Bank B, only deposits of amounts 2
and 20
are acceptable, and withdrawals of 22
must be paid by one 2
and one 20
note (i.e., $$22 = 2 + 20$$). If any transaction does not meet these criteria or if a withdrawal cannot be completed using the available deposits, the sequence of transactions is considered unsuccessful.
Your task is to determine if all transactions can be completed successfully in the given order.
inputFormat
The input is provided via standard input (stdin). The first line contains a single integer n
representing the number of transactions. Each of the following n
lines contains a transaction in the following format:type amount bank
where type
is either deposit
or withdraw
, amount
is an integer, and bank
is either A
or B
.
outputFormat
Output a single line to standard output (stdout) containing True
if all transactions can be completed successfully according to the rules, otherwise output False
.## sample
6
deposit 5 A
deposit 10 A
withdraw 15 A
deposit 2 B
deposit 20 B
withdraw 22 B
True