标签:des style http color java os io strong
3 3 1 2 3 3 1 2 4 4 1 9 100 10
1.000 2.000 8.000HintFor 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.
//15MS 268K
#include<stdio.h>
#include<algorithm>
using namespace std;
double s[57],array[107];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lf",&s[i]);
sort(s,s+n);
for(int i=1;i<n;i++)
{
array[k++]=s[i]-s[i-1];
array[k++]=(s[i]-s[i-1])/2;
}
sort(array,array+k);
for(int i=k-1;i>=0;i--)
{
bool flag=1;
double last=s[0],a=array[i];
for(int j=1;j<n-1;j++)
{
if(last==s[j])continue;
if(last+a<=s[j])last=s[j];
else if(s[j]+a<=s[j+1])last=s[j]+a;
else {flag=0;break;}
}
if(flag){printf("%.3lf\n",a);break;}
}
}
return 0;
}
HDU 4932 Miaomiao's Geometry 暴力,布布扣,bubuko.com
HDU 4932 Miaomiao's Geometry 暴力
标签:des style http color java os io strong
原文地址:http://blog.csdn.net/crescent__moon/article/details/38487785