- ← Back
- P1 (1)
- P1 (2)
- P2 (1)
- P2 (2)
- P3 (1)
- P3 (2)
- P3 (3)
- P3 (4)
- P4 (1)
- P4 (2)
- P4 (3)
- P4 (4)
- P4 (5)
- P4 (6)
- P4 (7)
- P4 (8)
- P5 (1)
- P5 (2)
- P5 (3)
- P5 (4)
- P6 (1)
- P6 (2)
- P6 (3)
- P6 (4)
- Гурток 1A
- Гурток 1B
- Гурток 1С
- Гурток 1D
- Гурток 1E
- Гурток 1F
- Гурток 2A
- Гурток 2B
- Гурток 2C
- Гурток 2D
- Гурток 2Е
- Гурток 2F
Penguins
Limits: 2 sec., 256 MiB
Zenyk and Marichka arrived to Antarctica to see some penguins. Well, they could have gone to Lviv for that.
Anyway, there are \(n\) penguins, and the \(i\)-th penguins is initially located in a point \((x_i, y_i)\) on a plane. The goal of the penguins is to meet in some point on the plane. As we know, penguins aren’t really good walkers, so in a second a penguin can go from point \((x, y)\) to either \((x+1, y)\) or \((x, y+1)\). Moreover, at any point of time, at most one penguin can walk.
What is the minimum time needed for all penguins to meet at the same point?
Input
The first line contains a single integer \(n\) — the number of penguins. The next \(n\) lines describe the initial coordinates of the penguins, which are integers.
Output
In a single line print a single integer — the answer to the problem.
Constraints
\(1 \le n \le 10^5\),
\(0 \le x_i, y_i \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 1 2 2 1 | 2 |
| Input (stdin) | Output (stdout) |
|---|---|
| 3 4 7 10 10 2 2 | 25 |
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|