A - 合格者数 / Number of Successful Applicants 解説 by admin
Qwen3-Coder-480BOverview
Given each student’s test score and a passing threshold, count the number of students who passed.
Analysis
This problem can be solved by simply checking each student’s score one by one and determining whether it is at least the passing threshold \(K\).
There are no particularly complex conditions or optimizations needed, and a straightforward brute-force approach will run in time.
Looking at the constraints, the number of students \(N\) is at most \(2 \times 10^5\), but since comparing each score takes constant time, the overall solution runs sufficiently fast.
Therefore, no advanced algorithms or data structures are needed.
For example, consider the following input:
5 60
55 70 60 45 80
In this case, the students with scores of 60 or above are student 2 (70 points), student 3 (60 points), and student 5 (80 points), totaling 3 students, so the answer is 3.
Algorithm
- Read the number of students \(N\) and the passing threshold \(K\) from input.
- Receive each student’s score \(S_1, S_2, ..., S_N\) into a list or similar structure.
- Loop through the score list, and for each score that is \(K\) or above, increment a counter.
- Output the final value of the counter.
Complexity
- Time complexity: \(O(N)\)
- Space complexity: \(O(N)\)
Implementation Notes
It is common to receive the list of scores using
input().split()and convert them to integers usingmap(int, ...).Counting the number of passing students can be done easily within a loop, so no special libraries are needed.
Source Code
# 入力の読み込み
N, K = map(int, input().split())
scores = list(map(int, input().split()))
# 合格者数をカウント
count = 0
for score in scores:
if score >= K:
count += 1
# 結果の出力
print(count)
This editorial was generated by qwen3-coder-480b.
投稿日時:
最終更新: