Banner Home Page Web Contests Problems Ranklist Status Statistics

Kill the monster

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 59   Accepted Submission(s) : 44
Problem Description
There is a mountain near yifenfei¡¯s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it. <br>Now we know yifenfei have n spells, and the monster have m HP, when HP &lt;= 0 meaning monster be killed. Yifenfei¡¯s spells have different effect if used in different time. now tell you each spells¡¯s effects , expressed (A ,M). A show the spell can cost A HP to monster in the common time. M show that when the monster¡¯s HP &lt;= M, using this spell can get double effect.<br>
 

Input
The input contains multiple test cases.<br>Each test case include, first two integers n, m (2<n<10, 1<m<10^7), express how many spells yifenfei has.<br>Next n line , each line express one spell. (Ai, Mi).(0<Ai,Mi<=m).<br>
 

Output
For each test case output one integer that how many spells yifenfei should use at least. If yifenfei can not kill the monster output -1.
 

Sample Input
3 100<br>10 20<br>45 89<br>5 40<br><br>3 100<br>10 20<br>45 90<br>5 40<br><br>3 100<br>10 20<br>45 84<br>5 40<br>
 

Sample Output
3<br>2<br>-1<br>
 

Author
yifenfei
 

Source
·Ü¶·µÄÄê´ú
 

Statistic | Submit | Back