Company: Ion Group - Hackerrank
Difficulty: hard
Given an array arr of n integers, modify the array to make it positive using the following operation: In a single operation, select an index i (0 <= i < n) and a value x (-10 18 <= x <= 10 18 ) and change arr[i] to x . An array is considered positive when the sum of each subarray of length greater than 1 is non-negative. More formally, after the operations the following condition should hold for all values of l and r where 0 <= l < r < n: arr[l] + arr[l+1] + ... + arr[r] >= 0 Determine the minimum number of operations required to make the array positive. Input Format The first line contains a single integer n , the size of the array. The second line contains n space-separated integers arr[0] arr[1] ... arr[n-1] . Output Format Print a single integer - the minimum number of operations required. Constraints 1 <= n <= 10 5 -10 9 <= arr[i] <= 10 9 , where 0 <= i < n Sample Input 0 5 -1 -1 -1 -1 -1 Sample Output 0 2 Explanation 0 It is possible to m