POJ 3258
来源:互联网 发布:什么是移动数据流量 编辑:程序博客网 时间:2024/06/04 17:55
解在一个有序区间,牵扯到试探区间各个数的可能,二分查找
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int l,m,n;int x[50005];bool C(int d){int cnt=0;int i,j;j=0;for(i=1;i<n+2;i++){if(x[i]-x[j]>=d) {cnt++;j=i;}}return cnt>=n+1-m;}int main(){freopen("in.txt","r",stdin);while(scanf("%d%d%d",&l,&n,&m)!=EOF){x[0]=0;for(int i=1;i<=n;i++) {scanf("%d",&x[i]);}x[n+1]=l;sort(x,x+n+2);int up=l;int low=0;int mid;int ans;while(low<=up){mid=(up+low)/2;if(C(mid)) {low=mid+1;ans=mid;}else up=mid-1;}cout << ans << endl;}return 0;}
0 0
- poj 3258
- POJ 3258
- POJ 3258
- poj 3258
- poj 3258
- POJ 3258
- POJ-3258
- poj 3258
- POJ 3258
- 【POJ】3258
- poj 2456 Aggressive cows poj 3258 (二分)
- POJ 3258 二分算法
- poj 3258 River Hopscotch
- poj 3258(二分。。。)
- poj-3258 River Hopscotch
- poj-3258 River Hopscotch
- poj 3258 二分 过河
- poj 3258 还是二分
- 树莓派的各种更新源
- 运算符重载详解
- 如何查找上网站外链成本
- 微信公众平台菜单自定义最简洁实用的教程(图文)
- select, poll和epoll的区别
- POJ 3258
- 升级python 带来的 yum 不能使用的问题
- Android-onInterceptTouchEvent()和onTouchEvent()总结
- 数据断点
- java学习笔记(四)面向对象
- Linux进程间通信——信号集函数
- 数据库设计技巧14则 - 数据库设计14个技巧
- IOS代码管控APP页面横竖屏切换
- select poll使用