#K93192. Minimum Watering Operations
Minimum Watering Operations
Minimum Watering Operations
You are given n plants, where each plant i requires a certain amount of water, denoted by w_i. In a single watering operation, you may water every plant that still has a positive water requirement. In this operation, you identify the smallest positive requirement m among the plants and subtract m from each plant that still needs water. The process is repeated until every plant has a water requirement of zero.
Your task is to compute the minimum number of watering operations required to make the water requirement of every plant equal to zero.
This can be thought of as repeatedly subtracting the minimum of the current positive elements until all elements become zero. The key observation is that the number of operations is equal to the number of distinct positive water requirements.
Mathematically, if the water requirements are given as \(w_1, w_2, \dots, w_n\), then the answer is the number of distinct values in \(\{ w_i \mid w_i > 0 \}\).
inputFormat
The input is given in two lines. The first line contains a single integer \(n\) (\(1 \leq n \leq 10^5\)), the number of plants. The second line contains \(n\) space-separated non-negative integers; the \(i\) th number represents the water requirement \(w_i\) for the \(i\) th plant (\(0 \leq w_i \leq 10^9\)).
outputFormat
Output a single integer on a new line, which is the minimum number of watering operations required so that all plants have a water requirement of zero.
## sample4
4 2 3 3
3
</p>