Company: IBM
Difficulty: medium
Question 1: Maximize Positive Meetings A product manager has to organize n meetings with different people. Meeting with each person results in an increase or decrease in the effectiveness index of the manager. The manager wants to organize the meetings such that the index remains positive for as many meetings as possible. Find the maximum number of meetings for which the effectiveness index is positive. The index at the beginning is 0 . Note: After the meetings begin, the index must remain above 0 to be positive. Input Format The first line contains an integer n , the number of elements in the effectiveness array. Each of the n subsequent lines contains an integer, effectiveness[i] , which represents the increase or decrease in effectiveness for each meeting. Output Format Print a single integer, the maximum possible number of meetings while maintaining a positive index. Constraints 1 ≤ n ≤ 10 5 -10 9 ≤ effectiveness[i] ≤ 10 9 Examples Input: 4 -3 0 2 1 Output: 3 One optima