Akuna CapitalOA #20
Effective Manager
Estimated EasyJudge-ready
Topics (AI-labelled)GreedyPrefix & Ranges
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.
Input
The first line contains n (1..100000), and 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 such that the index is strictly positive after each one ends.
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
Example notes
The example is taken from Goldman Sachs #22, which has the same statement; its schedule order shows that meetings can be reordered.
Editorial
Loading solution…