#K88852. Exact Bill Split
Exact Bill Split
Exact Bill Split
You are given an integer bill and a list of integers representing payment amounts. Your task is to determine whether the bill can be paid exactly using the given amounts. In other words, you need to check if the sum of the provided amounts is exactly equal to the bill.
Formally, given an integer \(B\) (the bill) and a list \(A = [a_1, a_2, \ldots, a_n]\), you need to check if
\[
\sum_{i=1}^{n} a_i = B
\]
If the equation holds, output True
, otherwise output False
.
Note that it is possible for the list to be empty. In such a case, the bill can only be split exactly if \(B = 0\).
inputFormat
The input is given from standard input (stdin
) and has the following format:
- The first line contains an integer B representing the bill amount.
- The second line contains an integer N which is the number of payment amounts.
- If N > 0, the third line contains N space-separated integers representing the payment amounts.
outputFormat
Output to standard output (stdout
) a single line containing True
if the sum of the amounts is exactly equal to the bill, or False
otherwise.
100
3
30 30 40
True
</p>