QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB

#23857. Pencils

统计

問題文

JOI 君は鉛筆を $N$ 本買うために近くの文房具店に行くことにした.

文房具店では鉛筆が一定の本数ずつのセットで売られている.セット $X$ は $A$ 本で $B$ 円,セット $Y$ は $C$ 本で $D$ 円である.

JOI 君はセット $X$ かセット $Y$ の一方を選び,選んだセットをいくつか購入する.両方のセットを購入することはできない.$N$ 本以上の鉛筆を得るために必要な金額の最小値を求めよ.

制約

  • $1 ≦ N ≦ 1000$
  • $1 ≦ A ≦ 1000$
  • $1 ≦ B ≦ 1000$
  • $1 ≦ C ≦ 1000$
  • $1 ≦ D ≦ 1000$

入力・出力

入力
入力は以下の形式で標準入力から与えられる.
$N$ $A$ $B$ $C$ $D$

出力
JOI 君が $N$ 本以上の鉛筆を手に入れるのに必要な金額の最小値を出力せよ.

入出力例

入力例 1
10 3 100 5 180

出力例 1
360

JOI 君は10本の鉛筆を入手したい.セット $X$ は3本で100円,セット $Y$ は5本で180円である.この時,セット $X$ を選んだ場合は,セットを4つ購入する必要があり400円必要である.セット $Y$ を選んだ場合は,セットを2つ購入する必要があり360円必要である.したがって,必要な金額の最小値は400円と360円の小さい方で360円である.


入力例 2
6 2 200 3 300

出力例 2
600

このとき,セット $X$ を選んだ場合もセット $Y$ を選んだ場合も必要な金額は600円である.必要な金額の最小値は600円である.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.