#P7948. Remaining Numbers After Repeated Deletions
Remaining Numbers After Repeated Deletions
Remaining Numbers After Repeated Deletions
You are given a sequence \(a\) of length \(n\) and \(q\) queries. For the \(i\)-th query, you are given a parameter \(k_i\). For each query, perform the following operations on a copy of the sequence:
- Compute the average \(\mathit{avg}\) of the remaining numbers.
- Delete all numbers that are strictly less than \(\mathit{avg} - k_i\); that is, remove every number \(x\) such that \(x < \mathit{avg} - k_i\).
- Repeat the above two steps until no number is deleted in one iteration.
- Output the count of numbers left at the end.
Note: The queries are independent; the deletions applied in one query do not affect the sequence for another query.
inputFormat
The input consists of multiple lines:
- The first line contains two integers \(n\) and \(q\) --- the length of the sequence and the number of queries.
- The second line contains \(n\) space-separated integers representing the sequence \(a\).
- Each of the next \(q\) lines contains a single integer \(k_i\) for the \(i\)-th query.
outputFormat
For each query, output a single integer on a new line, representing the number of numbers remaining after repeatedly deleting all numbers less than \(\mathit{avg} - k_i\).
sample
5 2
1 2 3 4 5
1
0
3
1
</p>