`
feiliboos
  • 浏览: 664467 次
文章分类
社区版块
存档分类
最新评论

The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest &&Dave

 
阅读更多
Problem Description
Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there are N (1<=N<=1000) people on the ground. Now he wants to know how many people will be in a square with the length of R (1<=R<=1000000000). (Including boundary).


Input
The input contains several cases. For each case there are two positive integers N and R, and then N lines follow. Each gives the (x, y) (1<=x, y<=1000000000) coordinates of people.



Output
Output the largest number of people in a square with the length of R.


Sample Input
3 2
1 1
2 2
3 3


Sample Output

3

题意:首先给你几个点,再给你个正方形边长,让你求出在以该边长为正方形最多能包含多少点。

思路:一开始听himdd学长讲了思路,说是用到了离散数学。。。很是纠结,,,不过上网看了看别人代码,大都是用枚举的方法,感觉挺不错的。先把所有点的纵坐标从小到大排序,然后在以每一点纵坐标为下边界,以该坐标+r为上边界,找出其所对应的横坐标,并记录,然后在把横坐标排序,以每一点的横坐标为左边界以该点的横坐标+r为右边界枚举,从而得出该正方形的可包含的最多的点。

代码:



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics