HDU 4007 Dave(离散化)
Dave
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 4095 Accepted Submission(s): 1390
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 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.
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,R;
struct Node
{
int x;
int y;
}node[],pos[];
bool cmp(Node a,Node b)
{
return a.x<b.x;
}
int main()
{
while(scanf("%d%d",&n,&R)!=EOF)
{
int ans=,cnt=,inf=,start,end,tot=;
for(int i=;i<n;i++)
{
scanf("%d%d",&node[i].x,&node[i].y);
}
sort(node,node+n,cmp);
for(int i=;i<n;i++)
{
tot=;
start=node[i].x,end=node[i].x+R;
for(int j=i;j<n;j++)
{
if(node[j].x>=start && node[j].x<=end)
{
pos[tot].x=node[j].y;
pos[tot++].y=;
pos[tot].x=node[j].y+R+;
pos[tot++].y=-;
}
}
sort(pos,pos+tot,cmp);
for(int j=;j<tot;j++)
{
cnt+=pos[j].y;
inf=max(inf,cnt);
}
ans=max(inf,ans);
}
printf("%d\n",ans);
}
return ;
}
HDU 4007 Dave(离散化)的更多相关文章
- hdu 4007 Dave(线性探查+枚举)
Problem Description Recently, Dave is boring, so he often walks around. He finds that some places ar ...
- hdu 4007 Dave (2011年大连ACM网络赛)
题意:给定正方形的边长 r ,在平面内寻找正方形可以圈住的点的最大的个数. 分析:先对点排序,然后固定一条边,再平移另一条垂直边,得到点的个数,最后比较大小即可. 注意:不包含正方形倾斜的情况! // ...
- HDU - 1255 扫描线+离散化进阶
这道题最开始我以为和HDU - 1542 那道题一样,只需要把cover次数改成2次即可,但是后面仔细一想,我们需要求的是覆盖次数大于等于2次的,这样的话,我们需要维护两个长度,HDU-1542 由于 ...
- HDU 5925 Coconuts 离散化
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5925 Coconuts Time Limit: 9000/4500 MS (Java/Others) ...
- hdu 5303 DP(离散化,环形)+贪心
题目无法正常粘贴,地址:http://acm.hdu.edu.cn/showproblem.php?pid=5303 大意是给出一个环形公路,和它的长度,给出若干颗果树的位置以及树上的果子个数. 起点 ...
- HDU 1711 kmp+离散化
http://acm.hdu.edu.cn/showproblem.php?pid=1711 Number Sequence Time Limit: 10000/5000 MS (Java/Other ...
- 2019 年百度之星·程序设计大赛 - 初赛一 C. HDU 6670 Mindis 离散化+dijkstra
题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=6670 Mindis Time Limit: 4000/2000 MS (Java/Others) M ...
- HDU 5862(离散化+树状数组)
Problem Counting Intersections 题目大意 给定n条水平或竖直的线段,统计所有线段的交点个数. (n<=100000) 解题分析 首先将线段离散化. 然后将所有线段按 ...
- Hdu 1856(离散化+并查集)More is better
题意:一些人遵循朋友的朋友也是朋友原则,现在找出最大的朋友圈, 因为人的编号比较大,但是输入的数据最多是10w行,所以可得出最多也就20w人,所以可以进行一下离散化处理,这样数据就会毫无压力 //// ...
随机推荐
- 机器学习(一) K-means聚类
聚类算法K-means是硬聚类算法,是目标函数聚类算法的代表.K-means算法以欧式距离作为相似度测度,它是求对应某一初始聚类中心向量V最优分类,使得评价指标J最小.算法采用误差平方和准则函数作为聚 ...
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- php函数: call_user_func()和call_user_func_array() 使用详解
call_user_func 该函数允许直接调用自己写的函数,可以直接传入一些参数. 使用方法1:给自己写的函数传入参数,一个特别的调用函数的方法. <?php funciotn test1($ ...
- Remmina:一个 Linux 下功能丰富的远程桌面共享工具(转载)
Remmina:一个 Linux 下功能丰富的远程桌面共享工具 作者: Aaron Kili 译者: LCTT geekpi | 2017-05-10 09:05 评论: 2 收藏: 4 Remm ...
- javascript上下文this
js的四种调用方式: 一 作为函数的调用: 在严格模式下this,undefined,在非严格模式下指向全局window对象. 二 作为方法调用: this通常指向调用的对象 三 作为构造函数的调用: ...
- HYSBZ1061题解
- Python 调用snmp自定义OID实现监控
http://kkkkkk.blog.51cto.com/468162/1172726 http://blog.csdn.net/mirahs/article/details/49619729
- 百度LBS开放平台个性化地图 制作一款独一无二的地图
百度LBS开放平台个性化地图 制作一款独一无二的地图 天天用百度地图的亲们是否已不再满足仅仅看例如以下的地图样式了呢? 默认百度地图样式 是否特别渴望看特别不一样的地图呢.如带京城81号气息的午夜蓝 ...
- xml方式封装通信数据方法
xml方式封装通信数据方法 public static function xmlToEncode($data) { $xml = ""; foreach($data as $key ...
- Java定时器TimeTask
package com.alan.timer; import java.util.Calendar;import java.util.Date;import java.util.Timer;impor ...