QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB

#23857. ดินสอ

Statistics

JOI-kun ตัดสินใจไปที่ร้านเครื่องเขียนใกล้บ้านเพื่อซื้อดินสอ $N$ แท่ง

ที่ร้านเครื่องเขียน ดินสอจะถูกขายเป็นชุดที่มีจำนวนแท่งคงที่ ชุด $X$ มี $A$ แท่ง ราคา $B$ เยน และชุด $Y$ มี $C$ แท่ง ราคา $D$ เยน

JOI-kun จะเลือกชุด $X$ หรือชุด $Y$ เพียงอย่างใดอย่างหนึ่ง แล้วซื้อชุดที่เลือกมาจำนวนหนึ่ง เขาไม่สามารถซื้อทั้งสองชุดปนกันได้ จงหาจำนวนเงินที่น้อยที่สุดที่ต้องใช้เพื่อให้ได้ดินสออย่างน้อย $N$ แท่ง

ข้อมูลนำเข้า

ข้อมูลนำเข้าจะถูกกำหนดให้จากอินพุตมาตรฐานในรูปแบบต่อไปนี้

N A B C D

ข้อมูลส่งออก

แสดงผลจำนวนเงินที่น้อยที่สุดที่ JOI-kun ต้องใช้เพื่อให้ได้ดินสออย่างน้อย $N$ แท่ง

ข้อจำกัด

  • $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$.

ตัวอย่าง

ข้อมูลนำเข้า 1

10 3 100 5 180

ข้อมูลส่งออก 1

360

คำอธิบาย

JOI-kun ต้องการดินสอ $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.