hdu4004 二分搜索
来源:互联网 发布:unity3d 2d游戏教程 编辑:程序博客网 时间:2024/05/17 23:54
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int l, n, m, a[500005];bool calc(int x){int step = 0, cur = 0;for(int i = 0; i <= n; ){if( ++step>m || a[i]-cur>x )return false;while( i <= n && a[i]-cur <= x )i++;cur = a[i-1];}return true;}int main(){while( scanf("%d%d%d", &l, &n, &m)!=EOF ){for(int i = 0; i<n; i++){scanf("%d", a+i);}a[n] = l;sort(a, a+n);int mid, left = 0, r = l;while( r>left ){mid = (left+r) >> 1;if( calc(mid) )r = mid;elseleft = mid+1;}printf("%d\n", r);}return 0;}
- hdu4004 二分搜索
- HDu4004 二分
- hdu4004 二分查找
- HDU4004 二分答案
- hdu4004之二分查找
- hdu4004(二分+贪心)
- hdu4004 简单二分+贪心
- hdu4004
- 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
- hdu4004(二分法)
- 二分搜索
- 二分搜索
- 二分搜索
- 关于排序的总结
- HDU3488:Tour
- 在Myeclipse中安装java Decompiler
- 骑士共存问题 (二分图最大匹配 转换 网络最大流 )
- ural 1057. Amount of Degrees(数位DP,4级)
- hdu4004 二分搜索
- SDJZ 判断三角形形状
- Android Bundle类
- 图像处理中的卷积与模板
- 单例设计模式
- SDJZ 子网掩码
- 使用Android.bat生成ant打包脚本
- 城里城外看SSDT
- CF 338E Optimize!