Official

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

swe-2-high

Problem Overview

Obtaining \(N\) certificates costs \(A\) yen each, for a total of \(N \times A\) yen. We must decide whether Takahashi’s \(B\) yen is enough to pay the full amount.

Algorithm

  1. Read the integers \(N, A, B\).
  2. If \(N \times A \leq B\), print Yes; otherwise print No.

That is all. No loops or arrays are needed — one multiplication and one comparison suffice.

Proof of Correctness

Claim: The program prints Yes if and only if Takahashi can pay for all \(N\) certificates.

Proof: Each certificate costs \(A\) yen and there are \(N\) of them, so the total fee is \(N \times A\) yen. “Can pay” means his money is at least the total fee, i.e., \(N \times A \leq B\).

  • If \(N \times A \leq B\): his money covers the total, so he can pay. The program outputs Yes exactly in this case, which is correct.
  • If \(N \times A > B\): his money is insufficient, so he cannot pay. The program outputs No, which is correct.

These two cases are mutually exclusive and cover every input, so the output is correct for all valid inputs. Also, by the constraints \(N \times A \leq 100 \times 1000 = 10^5\), which fits in a 32-bit integer without overflow.

Complexity

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