#P2629. 好消息,坏消息
好消息,坏消息
Description
Uim works as a secretary at a company. There are messages to inform the boss. Each message has a "goodness" value, which affects the boss’s mood. After a message is delivered, the boss’s mood becomes his previous mood plus this message’s goodness. Initially, the boss’s mood is . Once the boss’s mood falls below , he will fly into a rage and fire Uim.
To avoid being fired, Uim already knows the goodness values of these messages (which are arranged in chronological order) and wants to know how to prevent the boss from getting angry.
Uim can use a technique called "daoxu" ("倒叙"). For example, given messages, Uim can choose any integer (), first report events to , and then report events to . In particular, when , the messages are reported in the original order.
He wants to know how many such values of can keep the boss from getting angry.
Input Format
The first line contains an integer (), the number of messages.
The second line contains integers. In chronological order, the -th message has goodness ().
Output Format
One line with a single integer, the number of feasible choices of .
4
-3 5 1 2
2
Hint
Sample Explanation:
Feasible reporting orders (by indices) are or (corresponding to and , respectively).
Feasible reporting orders (by goodness values) are or .
Constraints:
For of the testdata, . For of the testdata, . For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号