cswork / OA打开练习工作台

Akuna CapitalOA #20

Effective Manager

估计简单可在线判题

考点(AI 标注)贪心调度前缀和区间

The effectiveness index starts at 0. Each meeting increases or decreases the index by effectiveness[i]. You may choose and reorder meetings freely; after each scheduled meeting ends, the index must be strictly greater than 0. Find the maximum number of meetings that can be scheduled.

This problem uses the CSWork standard input/output format. Akuna #20 and Goldman Sachs #22 have the same statement and ranges; since the original Akuna page has no examples, the illustrative example below is taken from #22 to make clear that meetings can be reordered.

输入格式

The first line contains n (1..100000), and the second line contains n integers effectiveness[i] (−10^9..10^9).

输出格式

Output the maximum number of meetings that can be attended in a row such that the index is strictly positive after each one ends.

样例 1

输入:

4
1 -20 3 -2

输出:

3

样例 2

输入:

1
0

输出:

0

样例 3

输入:

3
1 -1 1

输出:

3

样例说明

The example is taken from Goldman Sachs #22, which has the same statement; its schedule order shows that meetings can be reordered.