对于每一个点,可以找到他在x轴上的可行区域,这样的话就变为了对区间的贪心。

 #include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<cmath>
#include<stdlib.h>
using namespace std;
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define MAXN 10000001
#define INF 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define eps 1e-15 struct node{double s,t;}ma[];
double R;
int N; const int island_max=; void get_len(int index,double a,double b)
{
double temp = sqrt(R*R - b*b);
ma[index].s=a-temp;
ma[index].t=a+temp;
} int cmp(node a,node b)
{
if(a.t!=b.t)return (a.t < b.t);
return (b.s > a.s);
} int main()
{
int ca = ;
while(~scanf("%d%lf",&N,&R) && (N || R))
{
int i;
double a,b;
int flag = ;
for(i=;i<N;i++)
{
scanf("%lf %lf",&a,&b);
if(b<=R && !flag)
{
get_len(i,a,b);
}
else flag = ;
}
if(flag){printf("Case %d: -1\n",ca++);continue;}
sort(ma,ma+N,cmp);
double key = ma[].t;
int ans=;
for(i=;i<N;i++)
{
if(ma[i].s-key >eps)
{
key = ma[i].t;
ans ++;
}
}
printf("Case %d: %d\n",ca++,ans);
}
return ;
}

POJ1328Radar Installation(贪心)的更多相关文章

  1. poj1328Radar Installation 贪心

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64472   Accepted: 14 ...

  2. 【贪心】POJ1328-Radar Installation

    [思路] 以每一座岛屿为圆心,雷达范围为半径作圆,记录下与x轴的左右交点.如果与x轴没交点,则直接退出输出“-1”.以左交点为关键字进行排序,从左到右进行贪心.容易知道,离每一个雷达最远的那一座岛与雷 ...

  3. POJ1328Radar Installation(区间点覆盖问题)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 68597   Accepted: 15 ...

  4. POJ 1328 Radar Installation 贪心 A

    POJ 1328 Radar Installation https://vjudge.net/problem/POJ-1328 题目: Assume the coasting is an infini ...

  5. Radar Installation(贪心)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 56826   Accepted: 12 ...

  6. Radar Installation 贪心

    Language: Default Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42 ...

  7. POJ1328 Radar Installation(贪心)

    题目链接. 题意: 给定一坐标系,要求将所有 x轴 上面的所有点,用圆心在 x轴, 半径为 d 的圆盖住.求最少使用圆的数量. 分析: 贪心. 首先把所有点 x 坐标排序, 对于每一个点,求出能够满足 ...

  8. Radar Installation(贪心,可以转化为今年暑假不ac类型)

    Radar Installation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) ...

  9. poj 1328 Radar Installation(贪心+快排)

    Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea i ...

随机推荐

  1. Ural1076(km算法)

    题目大意 给出n*n表格,第a[i,j]表示i到j的权值,现在我们要将每个a[i,j]=sum[j]-a[i,j], 求出当前二分图a[][]最小匹配 最小匹配只需将权值取负后,求二分图最大匹配,使用 ...

  2. BZOJ2298: [HAOI2011]problem a

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2298 题解:刚开始思考的方向错了...一直在想LIS什么的,又发现不合法的情况不好判断,真是个 ...

  3. BZOJ2086: [Poi2010]Blocks

    题解: 想了想发现只需要求出最长的一段平均值>k即可. 平均值的问题给每个数减去k,判断是否连续的一段>0即可. 然后我们发现如果i<j 且 s[i]<s[j],那么 j 对于 ...

  4. C扩展Python - official docs - defining new type

    1. Code & Official_doc: THIS 2. My question. #include <Python.h> /* * 1.PyTypeObject doc, ...

  5. 【转】如何在eclipse里关联查看android源码

    原文网址:http://fengbohaishang.blog.51cto.com/5106297/1339556 以前没怎么注意过这个问题,不怎么看源码,现在发现源码确实是很好的学习资源. 直入正题 ...

  6. 【转】Linux时间函数之gettimeofday()函数之使用方法

    原文网址:http://blog.csdn.net/tigerjibo/article/details/7039434 一.gettimeofday()函数的使用方法: 1.简介: 在C语言中可以使用 ...

  7. 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(6)

    创建一个新文档(Creating a new document) 现在我们将尝试索引一些文档.对于我们的示例,让我们想象我们正在为我们的博客建立某种CMS.实体之一是博客的文章.使用JSON记法,在以 ...

  8. 关于Cocoapods安装与问题

    安装: 1.打开终端 2.如果网络没有FQ的话,需要通过淘宝的RubyGems镜像进行安装. 首先移除默认地址: gem sources --remove https://rubygems.org/ ...

  9. Python十分钟入门

    [简介] Python是一种动态解释型的编程语言.Python可以在Windows.UNIX.MAC等多种操作系统上使用,也可以在Java..NET开发平台上使用. [特点] 1. Python使用C ...

  10. Python 代码性能优化技巧

    选择了脚本语言就要忍受其速度,这句话在某种程度上说明了 python 作为脚本的一个不足之处,那就是执行效率和性能不够理想,特别是在 performance 较差的机器上,因此有必要进行一定的代码优化 ...