Under construction

Still being built. Things may change

ATM Transactions

Interview

Time limit1sMemory limit128 MB

Summary
Process ATM withdrawal or deposit lines, updating balance but rejecting withdrawals that push it below -200, until a sentinel line ends input.
Level

Easy2 of 10

Topics
Simulation, Implementation
Solved
No attempts yet

Problem

When a customer withdraws from or deposits money into an ATM, the bank must calculate the customer's new balance correctly. A customer may not overdraw the account by more than 200 dollars. Therefore, any withdrawal that would make the balance less than -200 must be rejected. A negative balance represents an overdraft.

Input

The input contains several transaction lines. Each line contains an integer starting balance, a letter W or D, and an integer amount. W means withdrawal and D means deposit.

The starting balance is between -200 and 10000, inclusive. The amount is between 5 and 400, inclusive.

Input ends with the line 0 W 0, which must not be processed as a transaction.

Output

For each transaction before the terminating line, print one line.

If the transaction is valid, print the new balance. If a withdrawal would make the balance less than -200, print Not allowed.

Examples1

  1. Example 1

    Input
    10000 W 10
    -200 D 300
    50 W 300
    0 W 0
    
    Expected output
    9990
    100
    Not allowed