#C890. Minimum Water to Buy
Minimum Water to Buy
Minimum Water to Buy
Emma has a set of water containers and for each container she has a required amount of water. However, she already has a certain amount of water available. Your task is to determine, for each test case, the minimum additional water Emma must purchase so that her total water meets the requirements.
For a given test case, let \(N\) be the number of containers, and let \(w_1, w_2, \dots, w_N\) denote the water requirements for each container. Emma currently has \(M\) units of water. The total required water is \(\sum_{i=1}^{N}{w_i}\). If this total exceeds \(M\), then Emma must buy exactly \(\sum_{i=1}^{N}{w_i} - M\) additional water. Otherwise, she does not need to purchase any additional water.
inputFormat
The first line contains an integer \(T\) denoting the number of test cases.
Each test case consists of three lines:
- The first line contains an integer \(N\) representing the number of containers.
- The second line contains \(N\) space-separated integers \(w_1, w_2, \dots, w_N\) indicating the water requirements for each container.
- The third line contains an integer \(M\) representing the water that Emma already has.
All input is read from standard input (stdin).
outputFormat
For each test case, output a single line containing the minimum additional water Emma needs to purchase. The answer for each test case should be printed on its own line, and output is written to standard output (stdout).
## sample2
4
5 3 6 2
10
3
4 5 7
8
6
8
</p>