본문 바로가기

BOJ/Python

[BOJ] 2975. Transactions

문제

Whenever somebody goes to an ATM to withdraw or deposit money, a calculation has to be done to keep the person's bank balance correct. Your task in this problem is to do such calculations. There is a bank rule that says that a customer may not have an overdraft of more than $200, so any withdrawal that would take the balance below –200 must be stopped. (A minus sign is used to indicate an overdraft, or negative balance).

입력

Input consists of a number of lines, each representing a transaction. Each transaction consists of an integer representing the starting balance (between –200 and +10,000), the letter W or the letter D (Withdrawal or Deposit), followed by a second integer representing the amount to be withdrawn or deposited (between 5 and 400). Input will be terminated by a line containing 0 W 0.

출력 

Output consists of one line for each line of input showing the new balance for each valid transaction If a withdrawal would take the balance below -200, the output must be the words ‘Not allowed’.

 

풀이

*간단한 트랜잭션 구현 

*잔액이 -200 미만이 되는 경우만 신경써서 처리하면 된다. 

 

'BOJ > Python' 카테고리의 다른 글

[BOJ] 1302. 베스트셀러  (0) 2020.03.13
[BOJ] 17530. Buffoon  (0) 2020.03.13
[BOJ] 5598. 카이사르 암호  (0) 2020.03.13
[BOJ] 2822. 점수계산  (0) 2020.03.13
[BOJ] 2941. 크로아티아 알파벳  (0) 2020.03.13