hdu 5428
来源:互联网 发布:手机身份证ocr识别软件 编辑:程序博客网 时间:2024/04/30 23:16
二分 加一下小判断
#include<stdio.h>#include<queue>#include<string.h>#include<algorithm>#include<map>#define ll long longusing namespace std;int a[2000000];int a1[2000000];int n;int j(int t){ memcpy(a1,a,sizeof(a)); for(int i=1;i<=n;i++) { if(a1[i]>a1[i-1]) a1[i]=max(a1[i-1]+1,a1[i]-t); else { if(a1[i]+t<=a1[i-1]) return 0; a1[i]=a1[i-1]+1; } } return 1;}int main(){ int t; int jj=0; scanf("%d",&t); while(t--) { int ans; jj++; scanf("%d",&n); a[0]=-10000000; for(int i=1;i<=n;i++) scanf("%d",&a[i]); int l=0,r=10000000; while(l<=r) { int mid=(r+l)>>1; if(j(mid)) {//printf("%d\n",mid); ans=mid; r=mid-1; } else l=mid+1; } printf("Case #%d:\n",jj); printf("%d\n",ans); }}
0 0
- HDU 5428
- HDU 5428
- hdu 5428
- hdu 5428
- HDU 5428 The Factor
- HDU 5428 The Factor
- hdu 5428 The Factor
- HDU 5428 The Factor
- HDU 5428:The Factor
- hdu 5428 The Factor
- HDU 5428 【水+因子。。?】
- HDU 5428 The Factor
- hdu 5428 The Factor
- hdu 5428(质因数分解)
- hdu
- hdu
- HDU
- hdu ()
- Rsync添加进程锁,防止重复进程
- 浏览器 WebBrowser 直接从内存数据显示图片而不是链接一个外部文件
- Spring MVC处理JSON数据(2)
- 用font awesome做一个网页导航栏(9块9包邮版微博个人主页布局)
- 使用Struts和POI实现Excel导出下载
- hdu 5428
- Java NIO之SocketChannel
- 深度模型知识库
- 基于Problem Solving with Algorithms and Data Structures using Python的学习记录(5)——Sorting
- c语言中的数组sizeof和strlen
- MySQL笔记-mysql用户管理
- JSP常用内置对象
- 前端开发弄懂了这些shell命令就足够了
- 页面置换算法——LRU