POJ3069(贪心)
来源:互联网 发布:unity3d开始界面添加 编辑:程序博客网 时间:2024/05/25 23:26
#include <iostream>#include <string>#include <map>#include <cstdio>#include <algorithm>#define FOR(i,n) for(int i=0;i<n;i++)using namespace std;int s[100115],x[101105];int main (){ int l,n; while(cin >> l >> n&&l!=-1&&n!=-1) { for(int i=0; i<n; i++) { cin >> s[i]; } sort(s,s+n); int i=0; int ans=0; while(i<n) { int k=s[i++];//左边第一个点 while(i<n&&s[i]<=k+l) i++;//找出接下来标记的点P int p=s[i-1]; while(i<n&&s[i]<=p+l) i++;//找出P能覆盖的最远的点 ans++; } cout << ans << endl; } return 0;}
0 0
- poj3069(贪心)
- POJ3069(贪心)
- poj3069(贪心)
- 贪心--poj3069
- POJ3069(贪心)
- poj3069贪心
- poj3069 贪心
- poj3069(贪心)
- poj3069贪心
- 贪心POJ3069
- poj3069贪心
- POJ3069 Saruman's Army Greedy(贪心)
- poj3069 Saruman's Army (贪心)
- poj3069 Saruman's Army(贪心,水)
- poj3069 Saruman's Army(经典贪心)
- POJ3069 Saruman's Army(贪心)
- poj3069贪心、思想、技巧
- poj3069简单贪心
- 6个常见的 PHP 安全性攻击
- matlab 2016b安装libsvm-3.22过程
- [乐意黎转载]AngularJS快速入门指南08:表格
- 多线程中的notify和wait方法的使用
- 2015上机一 输出字符串中连续出现最长的数字串及其开始的下标
- POJ3069(贪心)
- [iOS ] [[NSArray new] makeObjectsPerformSelector:@selector(<#selector#>)];
- 汇编语言课程主页
- python中除号/和//的区别
- js正则表达式验证密码格式的几种情况总结
- Mac OS X启动项详解
- linux电脑插入U盘自动挂载而不自动打开
- struts开发流程及详细
- 第八章 Spring Aware扩展