poj3069
来源:互联网 发布:js怎么设置cssimporant 编辑:程序博客网 时间:2024/06/07 03:19
题意:
求最少多少点加标记?
思路:
贪心:
AC代码:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <queue>#include <stack>#include <set>#define INF 0x3f3f3f#define ll long longusing namespace std;int a[1005];int main(){ int r,n; while(scanf("%d%d",&r,&n)!=EOF){ if(r==-1 && n==-1) break; for(int i=1; i<=n; i++){ scanf("%d",&a[i]); } sort(a+1,a+n+1); int ans=0; int left=0; int k=1; int s=0; while(k<=n){ s=a[k]; while(k<=n && a[k]<=s+r) k++; int p=a[k-1]; while(k<=n && a[k]<=p+r) k++; ans++; } cout << ans << endl; } return 0;}
0 0
- poj3069
- poj3069
- POJ3069
- poj3069
- POJ3069
- poj3069
- 贪心--poj3069
- POJ3069(贪心)
- poj3069贪心
- poj3069 贪心
- poj3069(贪心)
- poj3069贪心
- 贪心POJ3069
- poj3069贪心
- POJ3069标记点
- poj3069 Saruman's Army
- POJ3069 Saruman's Army
- poj3069贪心、思想、技巧
- Ubuntu14.04安装搜狗拼音输入法开机死机
- Anaconda中安装python3.4环境
- 编程基础——第三单元 数组
- [Baby steps giant steps] BSGS EXT-BSGS
- XML与html的区别
- poj3069
- 2015年底Google停止对eclipse的adt更新,转由eclipse团体提供
- 基于区域SURF的图像匹配算法研究
- LWIP 总述
- 编程基础——第四单元 字符串
- Android出现:Your project path contains non-ASCII characters.
- Eigen库数据结构内存对齐问题
- 【探索】在 JavaScript 中使用 C 程序
- 乱七八糟却非常重要的一些东西