#K62757. Missing Coins Value
Missing Coins Value
Missing Coins Value
You are given an integer \(S\) representing the total expected value of coins, and an integer \(N\) representing the number of coins that are available. You are also given \(N\) integers which represent the values of the existing coins. The task is to compute the missing coins' total value, which is defined as
[ Missing = S - \sum_{i=1}^{N} c_i ]
where \(c_i\) denotes the value of the \(i\)-th coin. If there are no coins present (i.e. \(N=0\)), then the missing value is simply \(S\). This problem requires handling multiple test cases.
inputFormat
The input begins with an integer (t) on the first line, indicating the number of test cases. For each test case:
- The first line contains two space-separated integers (S) and (N), where (S) is the total expected coin value and (N) is the number of coins available.
- If (N > 0), the second line contains (N) space-separated integers representing the values of the available coins. If (N = 0), the second line will be empty.
outputFormat
For each test case, output a single line containing the total value of the missing coins, calculated as (S - (\text{sum of values of available coins})).## sample
3
15 3
2 5 6
20 4
4 5 6 2
10 0
2
3
10
</p>