hdu 4004 The Frog's Games
来源:互联网 发布:淘宝客服回复客人刁难 编辑:程序博客网 时间:2024/05/16 05:06
二分答案:#include<iostream>#include<stdio.h>using namespace std;int a[500001];int b[500001];int l;;int n,m;bool ok(int mid){ int sum=0; int bsu=0; for(int i=1;i<=n+1;i++) { b[i]=a[i]-a[i-1]; sum=sum+b[i]; if(mid<b[i]) return false; if( sum>mid) { bsu++; i=i-1; sum=0; } else if(sum==mid) { bsu++; sum=0; } if(i==n+1&&bsu<=m) { return true; } if(bsu>=m&&i<n+1) { return false; } } return false;}int main(){ while(scanf("%d%d%d",&l,&n,&m)!=EOF) { for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } a[0]=0; a[n+1]=l; sort(a,a+n+1); int left=l/m; int right=l; while(right>=left) { int mid=(right+left)/2; if(ok(mid)) { right=mid-1; } else { left=mid+1; } } cout<<left<<endl; } return 0;}
- HDU 4004 THE FROG’S GAMES(二分)
- HDU 4004 The Frog's Games
- hdu 4004 The Frog's Games
- HDU 4004 The Frog's Games
- HDU 4004 The Frog's Games
- HDU 4004 The Frog's Games
- hdu 4004 The Frog's Games
- hdu 4004 The Frog's Games
- HDU 4004 The Frog's Games
- hdu 4004 The Frog's Games
- hdu 4004 The Frog's Games
- HDU 4004 The Frog's Games(二分)
- The Frog’s Games(hdu 4004)
- HDU 4004 The Frog's Games(二分)
- hdu 4004 - The Frog's Games
- HDU 4004 The Frog's Games
- HDU 4004 The Frog's Games
- HDU 4004 The Frog's Games
- 【STL】C++的迭代器Interator
- 使用apache common lang包下的StringEscapeUtils来对html,sql等特殊字符进行转义
- 谈谈我对攻读计算机研究生的看法
- lpstrCustomFilter
- 如何给普通用户添加管理自己相关内容的功能?
- hdu 4004 The Frog's Games
- ESQL(Entity SQL language )语法详解
- 为mysql添加应用程序驱动ODBC
- python 3 快速入门
- Android实战技术:Cursor相关的性能问题
- Large Division (大数取余,有个坑爹的地方)
- MyEclipse打包SWT浅析
- POJ 1179 Polygon 记忆化dfs vs dp
- TCP 三次握手