Official

A - サーバーへのリクエスト分散 / Distributing Requests to Servers Editorial by admin

GPT 5.2 High

Overview

This problem asks whether the total processing capacity \(A_i\) across all servers is at least \(M\), the number of requests generated over \(M\) days.

Analysis

Exactly 1 heavy request occurs per day, for a total of \(M\) requests. Each server \(i\) can handle up to \(A_i\) requests before it goes down.

The key observation is that there are no special constraints on “which server to assign on which day” (such as consecutive operation limits). In other words, as long as the total number of requests processed by each server does not exceed \(A_i\), all requests can be treated as identical units.

Therefore: - The total capacity across all servers is \(\sum_{i=1}^{N} A_i\) - The required total is \(M\)

So, if \(\sum A_i \ge M\), an assignment is always possible. In practice, if we sequentially assign requests to servers that still have remaining capacity, we will never get stuck as long as the total capacity is sufficient (since there will always exist a server with at least 1 remaining capacity).

Conversely, if \(\sum A_i < M\), no matter how we assign requests, the total processing capacity is insufficient, so it is impossible.

Concrete examples: - If \(A = [2, 1, 3]\), the total is \(6\). If \(M=5\), then \(6 \ge 5\), so Yes. - If \(A = [1, 1]\), the total is \(2\). If \(M=3\), then \(2 < 3\), so No.

One could naively “simulate the assignment day by day,” but since \(M\) can be up to \(10^9\), iterating over all \(M\) days would certainly result in a time limit exceeded. All we need is a comparison of totals.

Algorithm

  1. Read \(N, M\) and the array \(A\) as input.
  2. Compute \(S = \sum A_i\).
  3. If \(S \ge M\), output Yes; otherwise, output No.

Complexity

  • Time complexity: \(O(N)\) (just summing up \(A_i\))
  • Space complexity: \(O(N)\) (for storing the input array; can be reduced to \(O(1)\) if only the sum is maintained)

Implementation Notes

  • Since \(N\) is at most \(10^5\), the sum computation is sufficiently fast, but using sys.stdin.buffer.read() for input ensures stability.

  • \(\sum A_i\) and \(M\) can be up to around \(10^{14}\), but Python’s integers do not overflow, so they can be handled directly.

    Source Code

import sys

def main():
    data = list(map(int, sys.stdin.buffer.read().split()))
    N, M = data[0], data[1]
    A = data[2:2+N]
    print("Yes" if sum(A) >= M else "No")

if __name__ == "__main__":
    main()

This editorial was generated by gpt-5.2-high.