Number of Operations - Array
Anonymous User
294

We are given an array A of integers of size N. The array is one-indexed. We define the following operation on the array:
Let the index of the smallest non-negative (≥ 0) element of the array be i. We subtract i from each
element of the array such that each element aj becomes aj − i after the operation. If there are more than one elements of the least value, choose the one with the smallest index.
The task is to find the minimum number of such operations required so that each element of the array A becomes negative (< 0).

Constraints:
1 ≤ T ≤ 5 # Test Cases
1 ≤ N ≤ 10^5
1 ≤ a_i ≤ 10^9

Comments (0)