cswork / OA打开练习工作台

Goldman SachsOA #22

Effective Manager

估计简单可在线判题

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

Each meeting changes the index by an integer amount. You may rearrange the order of the meetings; find the maximum number of consecutive meetings such that the index is strictly greater than 0 after each one. The index starts at 0; an arrangement ends as soon as the index can no longer stay positive.

输入格式

The first line contains n (1..100000); 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 with the index strictly positive after each one.

样例 1

输入:

4
1 -20 3 -2

输出:

3

样例 2

输入:

1
0

输出:

0

样例 3

输入:

3
1 -1 1

输出:

3