Official

A - 合格者数 / Number of Successful Applicants Editorial by admin

GPT 5.2 High

Overview

This is a problem where you need to count and output how many of the students’ scores \(S_i\) meet or exceed the passing threshold \(K\).

Analysis

What we want to find is simply “the number of people satisfying \(S_i \ge K\)” — the order of scores or differences from the average are irrelevant.
Therefore, it is sufficient to look at each student’s score once and increment a counter whenever the condition is met.

For example, if \(K=60\) and the scores are \([55, 60, 80, 59]\), then \(60\) and \(80\) mean 2 people pass, so the answer is 2.

Although the constraint \(N \le 2\times 10^5\) is large, a single pass through the data is more than fast enough.
Conversely, approaches like sorting first and then counting (\(O(N\log N)\)) would also pass in many cases, but they involve unnecessary processing for this problem. Also, since the input is large, in Python a slow input method may (depending on the environment) cause time limit issues, so it is safer to use fast input.

Algorithm

  1. Read \(N, K\).
  2. Look at the \(N\) scores \(S_1,\dots,S_N\) in order, and increment a counter by 1 whenever \(S_i \ge K\).
  3. Output the final count.

In the implementation, something like sum(1 for s in scores if s >= K) is used to compute the count of elements satisfying the condition via summation.

Complexity

  • Time complexity: \(O(N)\) (checking each score once)
  • Space complexity: \(O(1)\) (can be processed without storing all scores. *Depending on the input reading method, additional space may be used)

Implementation Notes

  • Since the input can contain up to \(2\times 10^5\) elements, reading everything at once using sys.stdin.buffer.read() is faster.

  • It is sufficient to extract scores one by one with map(int, ...), check the condition, and count.

    Source Code

import sys

def main():
    data = sys.stdin.buffer.read().split()
    N = int(data[0])
    K = int(data[1])
    scores = map(int, data[2:2+N])
    ans = sum(1 for s in scores if s >= K)
    print(ans)

if __name__ == "__main__":
    main()

This editorial was generated by gpt-5.2-high.

posted:
last update: