#P9569. Balloon Ascension Selection

    ID: 22716 Type: Default 1000ms 256MiB

Balloon Ascension Selection

Balloon Ascension Selection

There are n balloons tied on a horizontal ground with an initial height of 0 meters at time 0 seconds. Each balloon is released (cut) at a given time and then ascends with a constant speed.

The ith balloon is released at time \( t_i \) seconds and, once released, ascends at a rate of \( v_i \) meters per second. Thus, if a balloon is released before or at time \( T \), its height at time \( T \) is calculated as:

[ \text{height}_i = \begin{cases} v_i \times (T - t_i), & \text{if } T \ge t_i, \ 0, & \text{if } T < t_i. \end{cases} ]

Your task is to determine the balloon with the highest height at time \( T \). In case multiple balloons share the maximum height, output the one with the smallest index (balloons are 1-indexed).

inputFormat

The first line contains two integers ( n ) and ( T ) separated by a space, representing the number of balloons and the moment at which you need to check the height, respectively. Each of the next ( n ) lines contains two integers ( v_i ) and ( t_i ), where ( v_i ) is the ascent speed (in meters per second) and ( t_i ) is the time (in seconds) at which the ( i\textsuperscript{th} ) balloon is released. It is guaranteed that all values are non-negative integers.

outputFormat

Output a single integer: the index of the balloon that is highest at time ( T ). If there are multiple balloons with the maximum height, output the smallest index among them.

sample

3 10
2 0
3 5
1 3
1