公式

A - 証明書の交付 / Issuing Certificates 解説 by admin

gpt-6-astra-medium

Overview

We need to find the total fee for \(N\) certificates and determine whether we can pay for them with our current money of \(B\) yen.

Analysis

Since each certificate costs \(A\) yen, the total fee for \(N\) certificates is \(N \times A\) yen. Therefore, the condition to be able to pay is as follows:

\(N \times A \leq B\)

For example, when \(N=3\) and \(A=200\), the total fee is \(600\) yen. If we have \(600\) yen, the answer is Yes, and if we have \(500\) yen, the answer is No.

Adding \(A\) yen \(N\) times to find the sum would also easily run within the time limit under these constraints. However, using multiplication eliminates the need for any loops.

Also, we can still pay if the money we have is exactly equal to the total fee. Be careful not to use \(N \times A < B\), as it will result in a Wrong Answer for this case.

Algorithm

  1. Read \(N, A, B\) as input.
  2. Calculate \(N \times A\).
  3. If \(N \times A \leq B\), print Yes; otherwise, print No.

This condition directly represents that “the money on hand is greater than or equal to the required fee,” so it correctly determines whether the payment is possible.

Complexity

  • Time complexity: \(O(1)\)
  • Space complexity: \(O(1)\)

Implementation Notes

  • Read the input as integers using map(int, sys.stdin.readline().split()).
  • Use N * A <= B for the condition to include the case where the amounts are equal.
  • Using Python’s conditional expression, the check and output can be written as follows:
print("Yes" if N * A <= B else "No")
  • Make sure the output matches the required case: Yes or No.

    Source Code

def main():
    import sys
    N, A, B = map(int, sys.stdin.readline().split())
    print("Yes" if N * A <= B else "No")

main()

This editorial was generated by gpt-6-astra-medium.