## Best Fishing Spot

View as PDF

Points: 7
Time limit: 1.0s
C++14 0.5s
Memory limit: 64M

Author:
Problem types
Allowed languages
C++, Java, JS, Python

There are fish swimming back and forth on an integer number line. The movements of each fish can be described by a pair of integers where represents that fish's home and represents the number of units in each direction from their home that they will reach by swimming. For example, if a fish is described by then they live at and reach anywhere in on the number line.

We are interested in finding the optimal spot on the number line to fish. This is the spot such that the number of fish that can reach it is maximized.

#### Input Specification

The first line contains
The next lines contains two space separated integers, and .

#### Output Specification

Output a single integer: the spot on the number that is reached by the most fish. If there are multiple such spots, output the lowest one.

#### Example

Suppose the following input:

3
-5 3
0 4
0 3

The expected output is:

-3

Reasoning: The first fish can reach , the second can reach , and the third reaches . All three fishes can reach points and , so we output the smaller number .

## Comments

There are no comments at the moment.