QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB

#23857. Bleistifte

İstatistikler

JOI-kun hat beschlossen, in ein nahegelegenes Schreibwarengeschäft zu gehen, um $N$ Bleistifte zu kaufen.

Im Schreibwarengeschäft werden Bleistifte in Sets mit einer festen Anzahl verkauft. Set $X$ enthält $A$ Bleistifte für $B$ Yen, und Set $Y$ enthält $C$ Bleistifte für $D$ Yen.

JOI-kun wählt entweder Set $X$ oder Set $Y$ aus und kauft eine bestimmte Anzahl des gewählten Sets. Er kann nicht beide Set-Arten gleichzeitig kaufen. Bestimme den minimalen Geldbetrag, der erforderlich ist, um mindestens $N$ Bleistifte zu erhalten.

Eingabe

Die Eingabe erfolgt über die Standardeingabe im folgenden Format.

N A B C D

Ausgabe

Gib den minimalen Geldbetrag aus, den JOI-kun benötigt, um mindestens $N$ Bleistifte zu erhalten.

Bedingungen

  • $1 \le N \le 1000$.
  • $1 \le A \le 1000$.
  • $1 \le B \le 1000$.
  • $1 \le C \le 1000$.
  • $1 \le D \le 1000$.

Beispiele

Eingabe 1

10 3 100 5 180

Ausgabe 1

360

Hinweis

JOI-kun möchte $10$ Bleistifte erhalten. Set $X$ enthält $3$ Bleistifte für $100$ Yen, und Set $Y$ enthält $5$ Bleistifte für $180$ Yen. Wenn er in diesem Fall Set $X$ wählt, muss er $4$ Sets kaufen, was $400$ Yen kostet. Wenn er Set $Y$ wählt, muss er $2$ Sets kaufen, was $360$ Yen kostet. Daher ist der minimale erforderliche Geldbetrag das Minimum aus $400$ Yen und $360$ Yen, also $360$ Yen.

Eingabe 2

6 2 200 3 300

Ausgabe 2

600

Hinweis

In diesem Fall beträgt der erforderliche Geldbetrag sowohl bei der Wahl von Set $X$ als auch bei der Wahl von Set $Y$ jeweils $600$ Yen. Der minimale erforderliche Geldbetrag beträgt $600$ Yen.

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.