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数组找到第一个和第三个会文串,然后暴力枚举判断是否存在中间的回文串 另外,在原字符串没啥用时可以直接覆盖,省去一个数组空间 ...
随机推荐
- 类扩展Extension
延展(Extension):在本类里声明私有方法. 1:延展定义的方法是在implemetation中. 2:声明的方法是私有方法. 3:延展中声明的方法可以不实现. #import "Ho ...
- Pig Latin-freecodecamp算法题目
Pig Latin 1.要求 Pig Latin把一个英文单词的第一个辅音或辅音丛(consonant cluster)移到词尾,然后加上后缀 "ay". 如果单词以元音开始,你只 ...
- 【转】pDc->SelectObject(pOldBrush)恢复画刷
请看下面的代码: CDC *pDc=new CClientDC(this); CBrush brush; brush.CreateSolidBrush(RGB(0,255,0)); CBrush * ...
- 拓扑排序 topsort
拓扑排序 对一个有向无环图(Directed Acyclic Graph简称DAG)G进行拓扑排序,是将G中所有顶点排成一个线性序列,使得图中任意一对顶点u和v,若边(u,v)∈E(G),则u在线性序 ...
- hash 哈希查找复杂度为什么这么低?
hash 哈希查找复杂度为什么这么低? (2017-06-23 21:20:36) 转载▼ 分类: c from: 作者:jillzhang 出处:http://jillzhang.cnblogs ...
- 如何用纯 CSS 创作一副国际象棋
效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/WyXrjz 可交互视频 ...
- pandas处理较大数据量级的方法 - chunk,hdf,pkl
前情提要: 工作原因需要处理一批约30G左右的CSV数据,数据量级不需要hadoop的使用,同时由于办公的本本内存较低的缘故,需要解读取数据时内存不足的原因. 操作流程: 方法与方式:首先是读取数据, ...
- [solution]腾讯TEG_计算广告组_算法题
度娘笔试归来,题目实打实的,感觉真心不易,上百号人就抢那么几个坑......只恨自己平时积累太少啊~ 故曝一道鹅厂面试用的算法题(当时我就死在了这题上),来为度娘家攒一下RP~ 题目: 对于长度为N的 ...
- 15年多校第一场七题hdu5294
要做这题,先要明白图的割,说白了就是 为了让原点无法到汇点要删几条边(之所以叫割,就是在图面上切一刀,减掉最小的边是原点和汇点成为两个集合),想到了割先放着一会用. 题中说只有沿最短路走才有可能追上, ...
- ie9/8的iframe中jQuery报错
此文章用于对工作中遇到的问题进行记录 jQuery 版本:1.9.1 按照一般的思路,jquery 1.x的是支持ie9及以下的,但是今天发现jquery报错了,代码错误位置在源码版本的第4888行 ...