DWITE Online Computer Programming Contest, November 2007, Problem 2
The task is to create a small application that will monitor financial transactions and keep a running total, displaying the balance at the end of each day. It should be assumed that the initial balance is zero, and balance is rolled over from one day to the next. Negative balance is a special event that will reset the balance to at the end of that day.
The input will contain five lines, each no more than characters long. Each line represents a stream of transactions with two possible characters
- each representing addition and subtraction of one unit from the running balance.
The output will contain five lines. Each line will have an integer, representing a balance at the end of that day's datastream. In a case that balance drops below during any particular stream,
OH NOES! should be printed to that line instead, and have the balance be reset back to , regardless of what follows on that line. Use the exact string output, all upper case, without quotes.
+++ ++- -----++++++++++ ++-+ --++
3 4 OH NOES! 2 2