A - 合格ライン / Passing Score 解説 by admin
Qwen3-Coder-480BOverview
A problem where you count the number of students whose scores fall below the passing threshold \(X\) from the class’s scores.
Analysis
This problem simply requires counting the number of values smaller than \(X\) from the given sequence \(A_1, A_2, \ldots, A_N\).
For example, if \(N = 5\), \(X = 60\), and the scores are \([45, 70, 55, 80, 60]\),
then 45 and 55 are less than 60, so the answer is 2.
Such a simple comparison only requires checking each element once, and no special techniques are needed.
Also, looking at the constraints, \(N\) is at most \(2 \times 10^5\), so an \(O(N)\) solution runs sufficiently fast.
Algorithm
- Read the number of students \(N\) and the passing threshold \(X\) from input.
- Read each student’s score \(A_1, A_2, \ldots, A_N\) as a list.
- For each score, check whether it is less than \(X\), and if so, increment a counter.
- Output the final value of the counter.
Complexity
- Time complexity: \(O(N)\)
- Space complexity: \(O(N)\)
Implementation Notes
When checking whether each score is strictly less than the threshold, use
score < X(not<=).Input can be read concisely using
map(int, input().split()).Source Code
# 入力の受け取り
N, X = map(int, input().split())
A = list(map(int, input().split()))
# Xより小さい点数の人数をカウント
count = 0
for score in A:
if score < X:
count += 1
# 結果の出力
print(count)
This editorial was generated by qwen3-coder-480b.