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数组找到第一个和第三个会文串,然后暴力枚举判断是否存在中间的回文串 另外,在原字符串没啥用时可以直接覆盖,省去一个数组空间 ...
随机推荐
- Unity3d 判断物体是否在可见范围内
unity中自带两个回调函数: void OnBecameVisible()//当物体可见时,回调一次. void OnBecameInvisible()//当物体不可见时,回调一次. 在untiy编 ...
- JS - encodeURI与encodeURIComponent的区别
encodeURI(String)主要用于整个URI(例如,http://www.jxbh.cn/illegal value.htm),而encodeURIComponent(String)主要用于对 ...
- LNMP一键安装包开启pathinfo和rewrite模式
此教程适用于集成安装包lnmp,官网是https://lnmp.org/ 一. 开启pathinfo #注释 下面这一行 #include enable-php.conf #载入新的配置文件 incl ...
- STM32HAL学习博客
https://www.cnblogs.com/wt88/category/1297945.html
- vmware10下载地址
https://download3.vmware.com/software/wkst/file/VMware-Workstation-Full-10.0.1-1379776.x86_64.bundle ...
- Android Studio中不能显示svn的上传下载两个图标同时version control为灰,不可点击
最近在接触Android Studio,涉及到svn的配置,因为是先安装的svn,后安装的Android Studio,后边同事告诉我, Android Studio 的SVN安装与其他IDE有很大差 ...
- excludeFromRecents标签
Android:excludeFromRecents控制在不在recent列表中显示. true时不显示:false显示,默认. 运行如下activity后,不会显示在recent列表中. <a ...
- 关于dispatch_sync死锁问题
首先,我们来看下下面一个例子: 代码:(串行队列里同步线程嵌套) NSLog(@"haha"); dispatch_queue_t queue = dispatch ...
- sql中group by 和having 用法解析
--sql中的group by 用法解析:-- Group By语句从英文的字面意义上理解就是“根据(by)一定的规则进行分组(Group)”.--它的作用是通过一定的规则将一个数据集划分成若干个小的 ...
- Python学习-day10 进程
学习完线程,学习进程 进程和线程的语法有很多一样的地方,不过在操作系统中的差别确实很大. 模块是threading 和 multiprocessing 多进程multiprocessing multi ...