[BOJ 6066] Buying Hay

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Farmer John is running out of supplies and needs to purchase H (1 <= H <= 50,000) pounds of hay for his cows.</p>

He knows N (1 <= N <= 100) hay suppliers conveniently numbered 1..N. Supplier i sells packages that contain P_i (1 <= P_i <= 5,000) pounds of hay at a cost of C_i (1 <= C_i <= 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.

입력 형식

  • Line 1: Two space-separated integers: N and H
  • Lines 2..N+1: Line i+1 contains two space-separated integers: P_i and C_i
  • </ul>

     

    출력 형식

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

       

      예제 입력

2 15
3 2
5 3

예제 출력

9

힌트

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

 


Comments

There are no comments at the moment.