#P2862. [USACO06JAN] Corral the Cows G
[USACO06JAN] Corral the Cows G
Description
Farmer John wishes to build a corral for his cows. Being finicky beasts, they demand that the corral be square and that the corral contain at least clover fields for afternoon treats. The corral's edges must be parallel to the axes.
FJ's land contains a total of clover fields, each a block of size and located at with its lower left corner at integer and coordinates each in the range . Sometimes more than one clover field grows at the same location; such a field would have its location appear twice (or more) in the input. A corral surrounds a clover field if the field is entirely located inside the corral's borders.
Help FJ by telling him the side length of the smallest square containing clover fields.
Input Format
Line : Two space-separated integers: and .
Lines : Each line contains two space-separated integers that are the coordinates of a clover field.
Output Format
Line : A single line with a single integer that is length of one edge of the minimum size square that contains at least clover fields.
3 4
1 2
2 1
4 1
5 2
4
Hint
Explanation of the sample:
|* *
| * *
+------
Below is one solution (C's show most of the corral's area); many others exist.
|CCCC
|CCCC
|*CCC*
|C*C*
+------
京公网安备 11011102002149号