#P16293. [蓝桥杯 2026 省 Java A 组] 奇怪的地图
[蓝桥杯 2026 省 Java A 组] 奇怪的地图
Problem Description
Xiao Lan is traveling in a certain country. The cities in this country are arranged on a hexagonal grid, as shown in the figure. Each hexagon in the figure represents a city.
:::align{center}
:::
If two cities share a common edge, then Xiao Lan can move from one city to the other in one step.
For any two cities, if it takes at least steps to walk from one city to the other, then the distance between these two cities is defined as . In other words, the distance here is the minimum number of steps between the two cities.
Each city can be represented by a unique coordinate . Its meaning is: starting from the city with coordinate , first walk steps along the direction, then walk steps along the direction, and you will reach that city.
Now you are given the coordinates of cities. You need to find, among these cities, the distance between the two cities that are farthest apart.
Input Format
The first line contains a positive integer , indicating the number of cities given.
The next lines each contain two integers , representing the coordinates of the -th city.
Output Format
Output one line containing one integer, representing the distance between the two farthest cities among the given cities.
4
0 -1
-1 -1
2 2
4 2
5
Hint
Sample Explanation
These four cities are exactly the four cities marked in the figure.
Among them, the farthest pair of cities is and . Starting from , you can first walk 3 steps in the upper-right direction to reach ; then walk 2 steps along the positive direction of the axis to reach .
The shortest distance between these two cities is 5, so the answer is 5.
Constraints
For of the testdata, .
For all testdata, , .
Translated by ChatGPT 5