POJ3069(贪心)
来源:互联网 发布:三级分销直销系统源码 编辑:程序博客网 时间:2024/05/19 03:23
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int N,R;int x[2100];int main(){#ifdef xxz freopen("in.txt","r",stdin);#endif // xxz ios::sync_with_stdio(false); cin.tie(0); int sum = 0; while(cin>>R>>N) { if(R == -1 && N == -1) break; for(int i = 0; i < N; i++) cin >> x[i]; sort(x,x+N); int j = 0, ans = 0; while(j < N) { int s = x[j++];//s是没有覆盖的最左边的点 while(j < N && s + R >= x[j]) j++;//一直向右前进直到距s的距离大于R的点出现 int f = x[j-1];//f是新加的上标记的点的位置 while(j < N && f + R >= x[j]) j++;//一直向右前进直到找到距f的距离大于R的点 ans++; } cout<<ans<<endl; } return 0;}
0 0
- 贪心--poj3069
- POJ3069(贪心)
- poj3069贪心
- poj3069 贪心
- poj3069(贪心)
- poj3069贪心
- 贪心POJ3069
- poj3069贪心
- poj3069贪心、思想、技巧
- poj3069(贪心)
- poj3069简单贪心
- poj3069【贪心,水】
- POJ3069-贪心水
- POJ3069(贪心)
- poj3069(贪心)
- POJ3069左右点贪心 贪心
- poj3069 Saruman's Army(贪心)
- POJ3069 Saruman's Army(贪心)
- 简单的mysql读写分离
- stm32 汇编点灯程序
- PHP配置文件中文版
- Web应用的组件化开发
- Redis配置简析(一)
- POJ3069(贪心)
- 三态选择树实现终结者
- Redis配置简析(二)之主从管理
- Android中GIF图的使用(GifView)
- lucene索引_加权操作、对日期和数字进行索引、IndexReader的设计
- netty源码理解
- 分享个INNO打包Windows应用程序完整实例脚本
- smali 指令集详解
- Linux启动过程详解