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数组找到第一个和第三个会文串,然后暴力枚举判断是否存在中间的回文串 另外,在原字符串没啥用时可以直接覆盖,省去一个数组空间 ...
随机推荐
- 02_5if switch分支与循环语句
02_5if switch分支与循环语句 1.语句 1.1条件语句-根据不同条件,执行不同语句. if if ... else if ... else if if ... else if ... el ...
- TabControl重写,添加关闭按钮
class userTabControl : TabControl { const int CLOSE_SIZE = 15; protected override void OnInvalidated ...
- Sum All Numbers in a Range-freecodecamp算法题目
Sum All Numbers in a Range 要求 给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. 最小的数字并非总在最前面. 思路 定义结果变量num 在for循环中,i ...
- numpy的linspace使用详解
文档地址: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html Parameters(参数): start ...
- deque 用法
引用博客:https://blog.csdn.net/zyq522376829/article/details/46801973 下面是那位大佬写的的笔记整理~~~~ deque - 双向队列 1.构 ...
- C++输入密码不显示明文
之前有遇到需求说输入密码不显示明文,但同时会有一些其他问题,暂时没做,如今经过尝试可以实现,但是得先知道要输入的是密码.主要利用的getch()函数的不回显特点.需要注意的是这个函数不是标准函数,而且 ...
- Ubuntu系统里的python
Ubuntu系统里,默认安装python2.7.x版本的python,直接执行python命令,打开的将是python 2.7.x版本:python3版本的需要自行安装,安装成功后,执行python3 ...
- 使用IAR在开发nordic问题记录
使用IAR在开发nordic的sdk的时候,官方有一段话*****Note for IAR 8 users:(Libraries for IAR 8 require wchar_t to be of ...
- Leetcode24--->Swap Nodes in Pairs(交换单链表中相邻的两个节点)
题目:给定一个单链表,交换两个相邻的节点,且返回交换之后的头节点 举例: Given 1->2->3->4, you should return the list as 2-> ...
- jmeter所有版本下载路径
https://archive.apache.org/dist/jmeter/binaries/