Goldman SachsOA #22
Effective Manager
Estimated EasyJudge-ready
Topics (AI-labelled)GreedyPrefix & Ranges
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.
Input
The first line contains n (1..100000); the second line contains n integers effectiveness[i] (−10^9..10^9).
Output
Output the maximum number of meetings that can be attended in a row with the index strictly positive after each one.
Example 1
Input:
4
1 -20 3 -2
Output:
3
Example 2
Input:
1
0
Output:
0
Example 3
Input:
3
1 -1 1
Output:
3
Editorial
Loading solution…