#B4010. Restaurant Attraction
Restaurant Attraction
Restaurant Attraction
There are n restaurants along a street. Little A stands at the very left end of this street. The i-th restaurant is located at a distance a_i from the left end, and its food has a deliciousness value b_i. The attraction of the i-th restaurant is defined as
Little A wants to visit the restaurant with the highest attraction, but he doesn't want to walk too far. In case of a tie (i.e. several restaurants having the same maximum attraction), he will choose the one that is nearest to the left end (i.e. with the smallest a_i). Output the index (1-indexed) of the chosen restaurant.
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), representing the number of restaurants. Each of the next n lines contains two positive integers ai and bi (1 ≤ ai, bi ≤ 109), representing the distance from the left end and the deliciousness value respectively.
outputFormat
Output a single integer – the 1-indexed restaurant number with the highest attraction. If there are multiple, output the one with the smallest distance ai.
sample
3
1 2
2 4
3 6
1