poj 3069
来源:互联网 发布:为什么看动漫知乎 编辑:程序博客网 时间:2024/06/02 02:55
#include <stdio.h>#include <stdlib.h>int a[1010];int cmp(int *a,int *b){ return *a-*b;}int main(){ int R,n,i,j,k,count;; while(scanf("%d%d",&R,&n)){ if(R==-1&&n==-1)break; count=0; for(i=0;i<n;i++) scanf("%d",&a[i]); qsort(a,n,sizeof(a[0]),cmp); i=0; while(i<n){ j=a[i++]; while(i<n&&a[i]<=j+R)i++; k=a[i-1]; while(i<n&&a[i]<=k+R)i++; count++; } printf("%d\n",count); } return 0;}贪心水题。
0 0
- POJ-3069&&POJ-2456
- POJ 3069
- POJ 3069
- poj----3069
- poj 3069
- POJ-3069
- poj-3069
- POJ 3069
- poj 3069
- poj 3069
- POJ 3069
- POJ 3069
- POJ 3069
- poj 3069
- POJ 3069
- poj 3069
- POJ 3069
- POJ 3069
- cframewnd oncreatecontrol
- 360通用防护 过滤用户输入的数据 实现防注
- opencv之计算图像的拉普拉斯变换
- QT跨目录编译及多工程集成(动态库的创建、引用及工程间相互依赖关系的pro文件编写方法)
- c实现replace功能
- poj 3069
- tomcat java.lang.IllegalArgumentException probe does not exist or is not a readable directory
- 一个查询Linux内核配置选项的好去处
- IT混搭成功实现Zblog评论留言的邮件和短信提醒
- Hibernate 关联关系
- hdu2098--拆分素数和--数论
- Floyd两种记录路径的方法
- ACM 矩形类定义
- Google搜索技巧-入门篇