A - 合格ライン / Passing Score Editorial by admin Editorial for printing
Claude 4.5 OpusOverview
This problem asks you to count the number of students among \(N\) students whose scores are below the passing threshold of \(X\) points.
Analysis
This problem is very simple and can be solved by checking each student’s score one by one and determining whether it is below the passing threshold.
Key Observations
- The expression “below” means \(A_i < X\) (note that it is not \(A_i \leq X\))
- For example, if the passing threshold is \(60\) points:
- A student with \(59\) points → needs remedial lessons (\(59 < 60\))
- A student with \(60\) points → does not need remedial lessons (\(60 < 60\) is false)
- A student with \(61\) points → does not need remedial lessons
Why a Naive Approach is Sufficient
In this problem, \(N \leq 2 \times 10^5\), so an \(O(N)\) algorithm that checks each student’s score once is fast enough. No special techniques are needed.
Algorithm
- Read \(N\) (number of students) and \(X\) (passing threshold)
- Read each student’s score \(A_1, A_2, \ldots, A_N\)
- For each score \(A_i\), determine whether \(A_i < X\)
- Count and output the number of students satisfying the condition
Concrete Example
Sample input:
5 60
45 60 70 55 80
- Student 1: \(45 < 60\) → needs remedial lessons ✓
- Student 2: \(60 < 60\) → false, so no remedial lessons needed
- Student 3: \(70 < 60\) → false, so no remedial lessons needed
- Student 4: \(55 < 60\) → needs remedial lessons ✓
- Student 5: \(80 < 60\) → false, so no remedial lessons needed
Answer: \(2\) students
Complexity
- Time complexity: \(O(N)\)
- Because we check each student’s score once
- Space complexity: \(O(N)\)
- Because we store all students’ scores in a list
Implementation Tips
In Python, you can use the generator expression
sum(1 for a in A if a < X)to concisely count the number of elements satisfying the conditionThis is equivalent to the following code:
count = 0 for a in A: if a < X: count += 1 print(count)Be careful not to confuse the comparison operators
<and<=(“below” means<)Source Code
N, X = map(int, input().split())
A = list(map(int, input().split()))
print(sum(1 for a in A if a < X))
This editorial was generated by claude4.5opus.
posted:
last update: