hdu4004
来源:互联网 发布:淘宝聊天工具怎么下载 编辑:程序博客网 时间:2024/06/05 22:42
/*
分析:
二分,水。。题。竟然ac了、着实捏了一把冷汗、1Y。。。
读完题后直接就想到二分了、不过看了数据范围后、感脚数据如果够强大
的话、是过不了滴。。当然、关键的系事实证明它咩有那么强大囧~~(不过
看到那个L的范围后着实被雷的里焦外嫩的、虽然acm里面不是第一次了、不过
你家养的蛤蟆经得起这样的折腾啊。。)
2013-07-03
*/
分析:
二分,水。。题。竟然ac了、着实捏了一把冷汗、1Y。。。
读完题后直接就想到二分了、不过看了数据范围后、感脚数据如果够强大
的话、是过不了滴。。当然、关键的系事实证明它咩有那么强大囧~~(不过
看到那个L的范围后着实被雷的里焦外嫩的、虽然acm里面不是第一次了、不过
你家养的蛤蟆经得起这样的折腾啊。。)
2013-07-03
*/
#include"iostream"#include"cstdio"#include"cstring"#include"algorithm"using namespace std;const int N=500005;int dir[N],dis[N];int main(){ int n,m,L; int i; int low,mid,up; int temp,max,cnt; while(scanf("%d%d%d",&L,&n,&m)!=-1) { dis[0]=0; for(i=1;i<=n;i++) scanf("%d",&dis[i]); dis[n+1]=L; sort(dis,dis+n+2); max=0; for(i=0;i<=n;i++) { dir[i]=dis[i+1]-dis[i]; if(max<dir[i]) max=dir[i]; } if(m>n) {printf("%d\n",max);continue;} low=max;up=L; while(low<=up) { mid=(low+up)>>1; i=cnt=0; while(i<=n && cnt<m) { cnt++; temp=mid; while(i<=n && dir[i]<=temp) { temp-=dir[i]; i++; } } if(cnt<=m && i>n) up=mid-1; else low=mid+1; } cout<<low<<endl; } return 0;}
- hdu4004
- hdu4004(二分法)
- HDu4004 二分
- hdu4004 二分查找
- HDU4004 二分答案
- hdu4004之二分查找
- hdu4004 二分搜索
- hdu4004(二分+贪心)
- hdu4004 简单二分+贪心
- hdu4004 The Frog's Games
- hdu4004 The Frog's Games 二分
- [二分答案]HDU4004 The Frog's Games
- hdu4004 Frog’s Game【二分+贪心】
- HDU4004 The Frog's Games(二分)
- 二分、三分小结(ZOJ3203 HDU2438 HDU4717 HDU2199 POJ3737 HDU4355 HDU3400 HDU4004)
- hdu4004 The Frog's Games 二分查找+贪心 TWT Tokyo Olympic 1COMBO-2
- 编译原理:LL(1),LR(0),SLR(1),LALR(1),LR(1)对比
- Java的安全学习(包括加密,数字签名,证书和认证)
- HDU_1757 A Simple Math
- 7.3学习andriod遇到问题的解决
- Java如何获取文件编码格式
- hdu4004
- The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
- 开始我的博客生涯~
- 数据库范式(1NF 2NF 3NF BCNF)详解一
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- 监控storm 的 作业收发数据情况
- git-daemon
- 生成ssh key
- 十大前端开发框架(下)