QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 256 MB Points totaux : 100

#22348. Buying Hay

Statistiques

Farmer John is running out of supplies and needs to purchase $H$ $(1 \le H \le 50,000)$ pounds of hay for his cows.

He knows $N$ $(1 \le N \le 100)$ hay suppliers conveniently numbered $1,\ldots,N$. Supplier $i$ sells packages that contain $P_{i}$ $(1 \le P_{i} \le 5,000)$ pounds of hay at a cost of $C_{i}$ $(1 \le C_{i} \le 5,000)$ dollars. Each supplier has an unlimited number of packages available, and the packages must be bought whole.

Help FJ by finding the minimum cost necessary to purchase at least $H$ pounds of hay.

Input

  • Line 1: Two space-separated integers: $N$ and $H$
  • Lines $2,\ldots,N+1$: Line $i+1$ contains two space-separated integers: $P_{i}$ and $C_{i}$

Output

  • Line 1: A single integer representing the minimum cost FJ needs to pay to obtain at least $H$ pounds of hay.

Examples

Input 1

2 15
3 2
5 3

Output 1

9

FJ can buy three packages from the second supplier for a total cost of 9.

Problem credits: Neal Wu, 2007

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.