14338 - 2024_IDS_Spring_Assignment3_Explosionnnn   

Description

chyen has a strong liking for young magical beings known as "lolis" particularly those who possess the skill of Burst Magic. He has a special fondness for lolis who excel at using Burst Magic. To fulfill this interest, he sets out to teach Burst Magic to all N lolis in his collection. However, he encounters a dilemma: despite acquiring the knowledge of Burst Magic, the lolis lack opportunities to showcase their magical prowess, which leads to a growing sense of discouragement.

In response, chyen makes a decision. He plans to take a group of these lolis on a daring expedition to confront a formidable monster. This monster has a health level of M, and the lolis have the chance to unleash their Burst Magic upon it. Nevertheless, there are specific conditions to consider. Each loli possesses her own magical strength, denoted as mi, and a measure of bravery, known as the courage value, represented by ci. A loli can successfully employ Burst Magic to deal damage equal to her magical strength mi, but only when the monster's health is equal to or less than her courage value ci. Once a loli uses her Burst Magic, she becomes fatigued and cannot cast the spell again.

Your task is to determine the minimum number of lolis that chyen needs to take along on this adventure to successfully defeat the monster. If it is not possible to defeat the monster under any circumstances, please output -1.

Input

The first line contains two integers, N and M, representing the number of lolis and the monster's health respectively.

The subsequent N lines each provide two numbers, mand ci, indicating the magical strength and courage value of the i-th loli.

  • 1 ≤ N, M ≤ 106
  • 1 ≤ mic≤ 106

Output

Output the minimum number of lolis required to defeat the monster, or -1 if this task cannot be accomplished.

Sample Input  Download

Sample Output  Download

Tags




Discuss