hdu 4932 BestCoder Round #4 1002
这题真是丧心病狂,引来今天的hack狂潮~
Miaomiao's Geometry
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 10 Accepted Submission(s): 3
There are 2 limits:
1.A point is convered if there is a segments T , the point is the left end or the right end of T. 2.The length of the intersection of any two segments equals zero.
For example , point 2 is convered by [2 , 4] and not convered by [1 , 3]. [1 , 2] and [2 , 3] are legal segments , [1 , 2] and [3 , 4] are legal segments , but [1 , 3] and [2 , 4] are not (the length of intersection doesn't equals zero), [1 , 3] and [3 , 4] are not(not the same length).
Miaomiao wants to maximum the length of segements , please tell her the maximum length of segments.
For your information , the point can't coincidently at the same position.
3
1 2 3
3
1 2 4
4
1 9 100 10
2.000
8.000
For the first sample , a legal answer is [1,2] [2,3] so the length is 1.
For the second sample , a legal answer is [-1,1] [2,4] so the answer is 2.
For the thired sample , a legal answer is [-7,1] , [1,9] , [10,18] , [100,108] so the answer is 8.
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<cmath>
#include<queue>
#define N 1005
#define MAXN 1000005
#define M 200
#define mod 1000000007
#define ll long long
using namespace std; int n,m;
int T;
ll a[N],b[N];
ll te;
ll ans; bool cmp(ll x,ll y)
{
return x>y;
} int isok(ll v)
{
ll now=;
for(int i=;i<=n-;i++){
// printf(" %I64d %I64d %I64d now=%I64d v=%I64d\n",a[i+1],a[i],a[i-1],now,v);
// printf(" %d\n",(a[i]-a[i-1]-now) <=v);
if( (a[i]-a[i-]-now) >=v){
now=;
}
else{
if( (a[i+]-a[i]) ==v){
now=;
i++;
}
else if( (a[i+]-a[i]) >v){
now=v;
}
else return ;
}
}
return ;
} int main()
{
int i,j,k;
//freopen("data.txt","r",stdin);
scanf("%d",&T);
//while(scanf("%d",&n)!=EOF)
while(T--)
// for(cnt=1;cnt<=T;cnt++)
{
scanf("%d",&n);
m=;
for(i=;i<=n;i++){
scanf("%I64d",&a[i]);
a[i]*=;
}
sort(a+,a++n);
//for(i=1;i<=n;i++)printf(" %I64d\n",a[i]);
for(i=;i<n;i++){
te=a[i+]-a[i];
b[m]=te;m++;
te/=;
b[m]=te;m++;
}
sort(b,b+m,cmp);
//for(i=0;i<m;i++)printf(" %I64d\n",b[i]);
for(j=;j<m;j++){
if(isok(b[j])==){
printf("%.3f\n",(double)b[j]/);
break;
}
} } return ;
}
hdu 4932 BestCoder Round #4 1002的更多相关文章
- HDU 5945 / BestCoder Round #89 1002 Fxx and game 单调队列优化DP
Fxx and game 问题描述 青年理论计算机科学家Fxx给的学生设计了一款数字游戏. 一开始你将会得到一个数\:XX,每次游戏将给定两个参数\:k,tk,t, 任意时刻你可以对你的数执行下面 ...
- HDU 5281 BestCoder Round #47 1002:Senior's Gun
Senior's Gun Accepts: 235 Submissions: 977 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 暴力+降复杂度 BestCoder Round #39 1002 Mutiple
题目传送门 /* 设一个b[]来保存每一个a[]的质因数的id,从后往前每一次更新质因数的id, 若没有,默认加0,nlogn复杂度: 我用暴力竟然水过去了:) */ #include <cst ...
- 矩阵快速幂---BestCoder Round#8 1002
当要求递推数列的第n项且n很大时,怎么快速求得第n项呢?可以用矩阵快速幂来加速计算.我们可以用矩阵来表示数列递推公式比如fibonacci数列 可以表示为 [f(n) f(n-1)] = [f(n ...
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 5643 BestCoder Round #75
King's Game Accepts: 249 Submissions: 671 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6 ...
- hdu 5641 BestCoder Round #75
King's Phone Accepts: 310 Submissions: 2980 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 贪心/二分查找 BestCoder Round #43 1002 pog loves szh II
题目传送门 /* 贪心/二分查找:首先对ai%=p,然后sort,这样的话就有序能使用二分查找.贪心的思想是每次找到一个aj使得和为p-1(如果有的话) 当然有可能两个数和超过p,那么an的值最优,每 ...
- Manacher BestCoder Round #49 ($) 1002 Three Palindromes
题目传送门 /* Manacher:该算法能求最长回文串,思路时依据回文半径p数组找到第一个和第三个会文串,然后暴力枚举判断是否存在中间的回文串 另外,在原字符串没啥用时可以直接覆盖,省去一个数组空间 ...
随机推荐
- NOIP模拟赛 不等数列
[题目描述] 将1到n任意排列,然后在排列的每两个数之间根据他们的大小关系插入“>”和“<”.问在所有排列中,有多少个排列恰好有k个“<”.答案对2012取模. [输入格式] 第一行 ...
- 【Git版本控制】git中reset命令的详解
git reset 命令详解(一) git reset 命令详解(二) reset命令的语法:git reset [选项] [版本号] [要回退的目标] 选项:--soft仅将head指针指向历史 ...
- 【linux】 服务器文件说明
文件名 说明 /etc/resolv.conf 域名解析服务器地址文件 /etc/services 服务程序对应端口号文件 /etc/passwd 登录账号文件 /etc/hosts 本地IP域名解 ...
- Linux下的jdk安装
我使用的是CentOS7,jdk使用的是JDK1.8 下载好以后,将jdk传到我自己的目录:/home/tool下,通过 tar -xzvf jdk-8u131-linux-x64.tar.gz解压 ...
- JFinal 结合Dubbo发生的一些问题
1.java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/co ...
- stm32L0系列学习(一)
开发用到的具体芯片是stm32L011F3 stm32L0总体特性,定位: 可见容量是比较少的,功耗很低,adc12位,7种低功耗模式 jlink和sdk的引脚关系图: HAL的库框图 官方给出的HA ...
- Mysql登陆、退出、更改环境编码
登录: mysql -h[数据库地址] -u[username] -p[password] -P[端口] //大写P表示端口,小写p表示密码 例如:mysql -hlocalhost -uroot ...
- HDU 3488 KM Tour
参考题解 这题注意有重边.. #include <cstdio> #include <cstring> #include <algorithm> using nam ...
- NetCore 2.0 应用程序在centos 7上通过docker发布
一 安装netcore 2.0 SDK 在centos 上面安装netcore 2.0 与window上面是不太一样的,注意,linux是不支持同时安装两个版本的.netcore SDK的,由于我之 ...
- 修改const变量
看下面的一段代码 ; int * j=(int*)(&i); // 运行正确,j确为i的地址,但 int *j=&i; 编译错误 *j=; //确实改变了i的值 printf(&quo ...