Cheerio Contest 1 J2 - Phys Ed Class

View as PDF

Submit solution

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

Problem type

A strange game is being played in P.E. class. In the game, N students are standing in a line, with the i^\text{th} student standing p_i meters away from the school. A ball is dropped on this line at a point T meters from the school. Students run towards the ball at a speed of one meter per second, and the first student to reach the ball wins. It is guaranteed that only one student will win. Can you determine which student will win the game?


For all test cases:

  • 1 \le N \le 2 \times 10^5
  • 0 \le T, p_i \le 10^9
  • Each student's name will not exceed 20 characters.
  • All student names are distinct.
  • There is only one winner.

Note: You must pass all test cases in order to earn points on this problem.

Input Specification

The first line contains two integers N and T.

The next N lines each contain a string, the name of the i^\text{th} student and an integer p_i.

Output Specification

Output the name of the student who will win.

Sample Input

5 10
Alice 2
Bob 7
Carol 8
Dave 13
Eve 17

Sample Output



There are no comments at the moment.