#K15786. Count Completely Filled Pots
Count Completely Filled Pots
Count Completely Filled Pots
You are given n pots, each with a maximum capacity of c units. You also have m bags of soil. Each soil bag contains a certain amount of soil. Starting from the first pot, you will use the soil bags sequentially to fill the pots. For each bag, fill the current pot until it reaches its capacity. If the current bag has remaining soil after filling the pot, move to the next pot and continue using the same bag until it is empty, and so on.
Your task is to compute and output the number of pots that are completely filled, i.e. that reach exactly c units of soil.
The relation can be expressed mathematically as:
$$ \text{filledPots} = \sum_{i=1}^{n} \mathbf{1}\{pot_i = c\} $$
where \(pot_i\) is the amount of soil in the \(i^{th}\) pot, and \(\mathbf{1}\{condition\}\) is the indicator function which is 1 if the condition is true and 0 otherwise.
inputFormat
The first line of input contains three integers n, c, and m, where 1 ≤ n, c, m ≤ 105.
The second line contains m space-separated integers representing the quantities of soil in each bag.
outputFormat
Output a single integer - the number of pots that are completely filled.
## sample3 10 5
4 2 6 8 3
2