Problems > Farthest by Manhattan

Farthest by Manhattan

Difficulty: 1600 3500 ms 128 MB

math geometry

Print the maximum Manhattan distance |xi−xj| + |yi−yj| over all point pairs.

Input: the first line has N (N ≥ 2); the next N lines each have x y.

Output: the maximum pairwise Manhattan distance.

Constraints:

  • 2 ≤ N ≤ 105
  • |coordinates| ≤ 106

Sample Tests

Input 1
3
0 0
2 3
-1 1
Output 1
5
Input 2
2
0 0
1 1
Output 2
2

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.