luogu#P5098. [USACO04OPEN] Cave Cows 3

[USACO04OPEN] Cave Cows 3

Problem Description

Farmer John's NN (1N50,0001 \le N \le 50,000) cows are exploring a large room in a cave. It is dark, and the cows communicate by mooing loudly at each other.
Due to the strange accoustics of the room, the time it takes for a 'moo' from one cow to reach another cow is proportional to the "manhattan" distance between the two cows: that is, if cow A is at location (Xa,Ya)(X_a, Y_a) and cow B is at location (Xb,Yb)(X_b, Y_b), it takes XaXb+YaYb|X_a-X_b| + |Y_a-Y_b| units of time for a 'moo' from cow A to reach cow B. XX and YY coordinates are all in the range (1,000,000..1,000,000)(-1,000,000 .. 1,000,000).

Given the locations of the NN cows, determine the maximum time over all pairs of cows for a 'moo' to propagate.

Input Format

  • Line 11: A single integer: NN.

  • Lines 2..N+12..N+1: Each line contains two space-separated integers, giving the (x,y)(x,y) coordinates of a cow.

Output Format

  • Line 11: The maximum 'moo' distance among all pairs of cows
5
1 1
3 5
2 7
8 1
4 4
12

Hint

OUTPUT DETAILS:

The cows at (2,7)(2,7) and (8,1)(8,1) are separated by 28+71=6+6=12|2-8| + |7-1| = 6 + 6 = 12 units.