P1089 [NOIP 2004 Senior] Jinjin's Savings Plan

Description

Jinjin manages her pocket money by herself. At the beginning of each month, mom gives Jinjin $300$ yuan. Jinjin makes a budget for that month’s expenses, and she always keeps the actual expenses equal to the budget. To teach Jinjin how to save, mom proposes that Jinjin may deposit any whole hundreds with her at any time, and at year end she will add $20\%$ and return it to Jinjin. Therefore, Jinjin makes a savings plan: at the beginning of each month, after receiving the pocket money from mom, if she expects that by the end of this month she will have at least $100$ yuan left on hand, she will deposit all the full hundreds with mom, keeping the remainder herself. For example, at the beginning of month $11$, Jinjin still has $83$ yuan on hand, and mom gives $300$ yuan. Jinjin plans to spend $180$ yuan in month $11$, so she deposits $200$ yuan with mom and keeps $183$ yuan. By the end of month $11$, Jinjin will have $3$ yuan left. Jinjin finds that the main risk of this savings plan is that the money deposited with mom cannot be withdrawn before year end. It may happen that at the beginning of some month, the money Jinjin has on hand plus this month’s money from mom is not enough for that month’s original budget. If this happens, Jinjin will have to scrimp that month and cut the budget. Now, given Jinjin’s monthly budgets from January to December of year $2004$, determine whether such a situation occurs. If not, compute how much money Jinjin will have on hand at the end of year $2004$, after mom returns the deposited money plus $20\%$ to Jinjin.

Input Format

$12$ lines of data, each containing a non-negative integer less than $350$, representing the budgets for months $1$ through $12$.

Output Format

A single integer. If, during the implementation of the savings plan, there is a month when the money is not enough, output $-X$, where $X$ is the first such month; otherwise, output how much money Jinjin will have on hand at the end of year $2004$. Note that on Luogu you should use standard input and output, not file I/O.

Explanation/Hint

Translated by ChatGPT 5