#K46117. Minimum Operations to Zero Light Bulbs
Minimum Operations to Zero Light Bulbs
Minimum Operations to Zero Light Bulbs
In this problem, you are given several test cases. In each test case, you are provided with a list of light bulbs, each having an initial brightness represented by a non-negative integer. In one operation, you can reduce the brightness of all light bulbs that have a brightness greater than zero by 1. Your task is to calculate the minimum number of operations required to turn off all the light bulbs (i.e. make the brightness zero for every light bulb).
Mathematically, if a test case is represented by an array \(A = [a_1, a_2, \dots, a_n]\), then the minimum number of operations required is given by:
[ \text{operations} = \max{a_1, a_2, \dots, a_n} ]
This is because during each operation, every light bulb with a non-zero brightness is decremented by 1, and the bulb that initially has the maximum brightness will determine the total number of operations needed.
inputFormat
The input is given via standard input (stdin) with the following structure:
- The first line contains a single integer \(T\) representing the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the number of light bulbs.
- The second line contains \(N\) space-separated integers representing the initial brightness values of the light bulbs.
All values are non-negative integers.
outputFormat
For each test case, output a single integer on a new line which represents the minimum number of operations required to turn all the light bulbs off (i.e., reduce their brightness to zero).
Output the result via standard output (stdout).
## sample1
3
3 3 4
4
</p>