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QAAAAAyFDPj0uL9n3+5YVDqgFn2sffGAkRhfZmc33Z3F77s/VC4cwignBMsqbTM2uV41qmyMMbp00lTeFjnYyfDTceIl805pRXwL/ZQXAyrgDmkv5Yyogl821oSKqRXGu+qYFtGXNzZpYtM8au33Fc26xhXMaCq7o7fhhd5hpH/mIRxHEBAAAAoMbFvApMHNeK4Crzcd2DuU4BAAAAAMAl4Qo6LgAAAAAAAJcEOC4AAAAAACg1DMe98O1f+779a/7iX765+Jc/X/jL131/+arv2y/z3/bmv819c/G//3zxv/588dzXF899ffFPX1/44qsLX3x14Y9fXfjjVxd6vtT53HBijW4AAAAAAACuKHTh279e+Pavfd/+JX/xL99csDT3PKO5pun+yWa6rOxavgsAAAAAAMBlwwi2miHX/w9fC8aDVwAD+QAAAABJRU5ErkJggg==" alt="" />
链接:点我
二分代价,由于序列是单增的,我们使前面一个数相对取最小,这样后面的数变化的值也能相对较小wa了好多次,发现上限少取了个0
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt;
int a[MAXN],b[MAXN];
bool check(int mid)
{
for(int i=;i<=n;i++)
{
b[i]=a[i];
}
for(int i=;i<=n;i++)
{
if(i==)
{
b[i]-=mid;
continue;
}
if(b[i]<=b[i-])
{
if((b[i-]+)-b[i]<=mid)
b[i]=b[i-]+;
else
{
return ;
} }
if(b[i]-mid>b[i-])
{
b[i]=b[i]-mid;
}
else
{
b[i]=b[i-]+;
}
}
return ; }
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
int ca=;
scanf("%d",&tt);
while(tt--)
{
printf("Case #%d:\n",ca++);
scanf("%d",&n);
for(i=;i<=n;i++) scanf("%d",a+i);
int l=;
int r=;
int ans=;
while(l<=r)
{
int mid=(l+r)>>;
if(check(mid))
{
ans=mid;
r=mid-;
}
else
l=mid+;
}
printf("%d\n",ans);
}
}
hdu 5248 贪心的更多相关文章
- Hdu 5289-Assignment 贪心,ST表
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...
- hdu 4803 贪心/思维题
http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么? G++ AC C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上 ...
- hdu 1735(贪心) 统计字数
戳我穿越:http://acm.hdu.edu.cn/showproblem.php?pid=1735 对于贪心,二分,枚举等基础一定要掌握的很牢,要一步一个脚印走踏实 这是道贪心的题目,要有贪心的意 ...
- hdu 4974 贪心
http://acm.hdu.edu.cn/showproblem.php?pid=4974 n个人进行选秀,有一个人做裁判,每次有两人进行对决,裁判可以选择为两人打分,可以同时加上1分,或者单独为一 ...
- hdu 4982 贪心构造序列
http://acm.hdu.edu.cn/showproblem.php?pid=4982 给定n和k,求一个包含k个不相同正整数的集合,要求元素之和为n,并且其中k-1的元素的和为完全平方数 枚举 ...
- HDU 2307 贪心之活动安排问题
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2037 今年暑假不AC Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 1052 贪心+dp
http://acm.hdu.edu.cn/showproblem.php?pid=1052 Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS ...
- HDU 2111 Saving HDU【贪心】
解题思路:排序后贪心,和fatmouse's trade 类似 Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: ...
- HDU 2831 (贪心)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2831 题目大意:植物大战僵尸.给定种植植物时间间隔t,以及每个僵尸的到达时间v,生命d.问是否能赢. ...
随机推荐
- css 实现圆形头像
1.方法一 直接设置img为圆形,这种情况下如果图片不是正方形,图片会被拉伸 <img class="circleImg" src="../img/photo/im ...
- ASM配置OGG
两种方法:http://blog.sina.com.cn/s/blog_aa84cfe40101lsks.html 使用ACFS配置OGG:http://ylw6006.blog.51cto.com/ ...
- 使用 script 命令记录用户操作行为
Script 命令可以帮助管理员记录用户的操作行为,包括用户查看文件中的哪些具体内容,写入了哪些文件,写了些什么都能看到,比较详细的记录了用户的操作行为. 本文对此进行简要说明. 1.添加日志记录 e ...
- java递归遍历获取目录下所有文件
import java.io.File; import java.util.ArrayList; import java.util.List; public class GetFiles { Arra ...
- vue总结 08状态管理vuex
状态管理 类 Flux 状态管理的官方实现 由于状态零散地分布在许多组件和组件之间的交互中,大型应用复杂度也经常逐渐增长.为了解决这个问题,Vue 提供 vuex:我们有受到 Elm 启发的状态管 ...
- python面向对象(二)之封装
封装定义: 在程序设计中,封装(Encapsulation)是对具体对象的一种抽象,即将某些部分隐藏起来,在程序外部看不到,其含义是其他程序无法调用. 即"封装"就是将抽象得到的数 ...
- Python装饰器讲解
Python装饰器讲解 定义:本质是函数,就是为其他函数添加附加功能.原则:1.不能修改被装饰的函数的源代码 2.不能修改被装饰的函数的调用方式 import time def timmer(func ...
- Master和worker模式
让和hadoop的设计思想是一样的,Master负责分配任务和获取任务的结果,worker是真正处理业务逻辑的. 使用ConcurrentLikedQueue去承载所有的任务,因为会有多个worker ...
- 定制Eclipse
转载自http://chriszz.sinaapp.com 一般从Eclipse官网eclipse.org下载的,都是打包好的版本,比如标准版.jee版.java版.c++版.php版.测试版等.有时 ...
- python实现获取系统版本和mac信息上传到指定接口
import os,platform,uuid,urllib.parse,urllib.request,json def BeforeSystemRequests(): ''' the systemi ...