337. Bank Account Statement
MediumSimulation
Process transactions on an account starting at balance 0: D x deposits x, W x withdraws x only if the balance is enough (otherwise the transaction is rejected). Print the final balance and the number of rejected withdrawals.
Input format
Line 1: q Next q lines: D x or W x
Output format
balance rejected
Example 1
Input
5 D 100 W 30 W 100 D 50 W 120
Output
0 1
Example 2
Input
1 W 5
Output
0 1
Constraints
1 ≤ q ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…