← 返回 goldmansachs 的题目列表Effective Manager
类型:online_judge
Given a product manager who needs to organize n meetings, each meeting has an effectiveness index in the list. After meeting with the specified number of meetings, the index must be positive. Find out the maximum number of meetings that can be organized. If the index is negative before the meetings, the index at the beginning is 0.
Example:
Input: n = 4, effectiveness = [1, 3, -2, -1] Output: 3
The first triplet with a positive index is (1, 3, -2) where 1 + 3 - 2 + 1 = 3, which is a valid solution.
Function Description:
Complete the function maxMeetings with the following parameter:
int effectiveness[]: effectiveness increase/decrease for each meeting
Return:
int: maximum number of meetings while keeping the index positive.
Constraints:
1 ≤ n ≤ 10^5
-10^5 ≤ effectiveness[i] ≤ 10^5
Example
Input
4
1 3 -2 -1