当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3179:Corral the Cows

题目描述
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 C (1 <= C <= 500) clover fields for afternoon treats. The corral's edges must be parallel to the X,Y axes.

FJ's land contains a total of N (C <= N <= 500) clover fields, each a block of size 1 x 1 and located at with its lower left corner at integer X and Y coordinates each in the range 1..10,000. 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 C clover fields.
输入解释
Line 1: Two space-separated integers: C and N

Lines 2..N+1: Each line contains two space-separated integers that are the X,Y coordinates of a clover field.
输出解释
Line 1: A single line with a single integer that is length of one edge of the minimum size square that contains at least C clover fields.
输入样例
3 4
1 2
2 1
4 1
5 2
输出样例
4
提示
Explanation of the sample:

|*   *

| * *
+------
Below is one 4x4 solution (C's show most of the corral's area); many others exist.

|CCCC

|CCCC
|*CCC*
|C*C*
+------

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3179

最后修改于 2020-10-29T06:55:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536