题目

裸的贪心。

基本思想见图:

Code:


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; const int N = 15001; int T;
int cnt,n,L,W;
int ans; struct rou
{
int l;
int r;
}a[N]; bool cmp(rou x,rou y)
{
return x.l<y.l;
} void work()
{
cnt=0;
ans=0;
//这是一个很日学的东西,卡了我一个星期。
//以后一看见“有多组数据”,就想到work函数内付0.
scanf("%d%d%d",&n,&L,&W);
for(int i=1;i<=n;++i)
{
int C,R;
scanf("%d%d",&C,&R);
if(2*R<=W)
continue;
a[++cnt].l=C-sqrt(R*R-W*W/4.0);
a[cnt].r=C+sqrt(R*R-W*W/4.0);
} sort(a+1,a+cnt+1,cmp); int t=0;
while(t<L)
{
++ans;
int s=t;
for(int i=1;i<=cnt;++i)
if(a[i].l<=s&&t<a[i].r)
t=a[i].r;
if(t==s&&t<L)
{
printf("-1\n");
return;
}
}
printf("%d\n",ans);
} int main()
{
scanf("%d",&T);
for(int t=1;t<=T;++t)
work();
return 0;
}

血泪啊!

一定要吸取教训啊!!

啊!!!

最新文章

  1. web开发工具软件使用问题记录
  2. WIN7下使用VC2010调试uCOS-II 2.91
  3. Hadoop组成
  4. 解决vsftpd日志时间问题
  5. UC编程之线程
  6. jquery获取表单的值
  7. SQL Server 的远程连接(转载)
  8. Course Schedule ——LeetCode
  9. 感兴趣的Linux发行版
  10. iOS开发之使用Ad Hoc进行测试
  11. 关于ASP.NET WebAPI中HTTP模型的相关思考
  12. Android studio出现Error:Unable to tunnel through proxy. Proxy returns &quot;HTTP/1.1 400 Bad Reques的解决办法
  13. 将Windows 8.1 系统窗口背景设置成淡绿色?
  14. vue项目如何通过前端实现自动识别并配置服务器环境地址
  15. 【BZOJ1818】[CQOI2010]内部白点(树状数组,扫描线)
  16. producter-consumer 他山之石
  17. 关于xftp上传文件状态错误的解决
  18. 深入探讨 Java 类加载器(转载)
  19. 调试一个Ext打开的window窗口内嵌Iframe的form提交问题
  20. jeesite介绍及链接

热门文章

  1. 2.1 MySQL基础使用
  2. notepad++常用命令
  3. k8spod的介绍
  4. mybatis+spring boot+vue
  5. javascript ----一些边距知识
  6. Kali中文乱码问题
  7. C++ STL之动态数组vector(⽮量)的使⽤
  8. android传递数据bundle封装传递map对象
  9. ch3 盒模型、定位
  10. 启动易EZB Systems EasyBoot V6.5.1.669 + 注册码