Full chinazes
Limits: 2 sec., 512 MiB
This statement was translated automatically from Ukrainian.
Zenyk finished competing in ICPC, graduated from university, and got a job. Sometimes he earns money, and sometimes he spends it. Currently, Zenyk has \(0\) hryvnias in his account.
In total, Zenyk performed \(n\) actions; in the \(i\)-th action, he either earned \(a_i\) hryvnias or spent \(a_i\) hryvnias.
If at any point in time Zenyk’s balance was negative, he was in debt. Otherwise, in Zenyk’s opinion, a full chinazes occurred. Help Zenyk determine if his balance was ever negative!
Input
The first line contains a single integer \(n\). The \(i\)-th of the next \(n\) lines can have one of the following two formats:
earn\(a_i\), which means that Zenyk earned \(a_i\) hryvnias;spend\(a_i\), which means that Zenyk spent \(a_i\) hryvnias.
Output
If Zenyk was never in debt during the given \(n\) actions, print chinazes on
a single line. Otherwise, print debt.
Constraints
\(1 \leq n \leq 100\),
\(1 \leq a_i \leq 100\),
\(a_i\) are integers.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 3 earn 5 spend 6 earn 5 | debt |
| Input (stdin) | Output (stdout) |
|---|---|
| 4 earn 69 spend 42 earn 42 spend 69 | chinazes |
Notes
In the first example, Zenyk’s balance after the first action is \(5\), after the second: \(-1\), after the third: \(4\). Despite the fact that his final
balance is non-negative, after the second action Zenyk was in debt, so
we must print debt.
In the second example, Zenyk’s balances after the given \(4\) actions are \([69, 27, 69, 0]\); they were never negative.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|