#K72277. Count Passing Students
Count Passing Students
Count Passing Students
Problem Statement:
Given a list of n students and their respective grades, answer q queries where each query contains a passing threshold. For each query, determine the number of students whose grades are greater than or equal to the given threshold.
For a query with passing grade X, you must compute
$$\text{count} = \sum_{i=1}^{n} \mathbf{1}\{grade_i \ge X\}, $$where (\mathbf{1}{grade_i \ge X}) equals 1 if (grade_i \ge X) and 0 otherwise. Your solution should efficiently process multiple queries.
Constraints:
- 1 \(\le n \le 10^5\)
- Each grade is an integer in the range [0, 100].
- 1 \(\le q \le 10^4\)
You are required to read from standard input and output the result to standard output.
inputFormat
Input Format (from stdin):
- The first line contains an integer \(n\), which is the number of students.
- The second line contains \(n\) space-separated integers representing the grades of the students.
- The third line contains an integer \(q\), which is the number of queries.
- The fourth line contains \(q\) space-separated integers, each representing a passing grade threshold.
outputFormat
Output Format (to stdout):
Output (q) integers in one line separated by spaces. Each integer corresponds to the number of students who have a grade that is greater than or equal to the respective query threshold.## sample
5
50 75 90 60 85
3
60 80 50
4 2 5
</p>