标签:
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #include<queue> #include<algorithm> using namespace std; const int N=1e5+10; const int M=50000; const int INF=0x3f3f3f3f; double a[100], b[200]; ///b数组保存两点之间的长度及其一半 int n; int Judge(double d) ///判断d能不能当满足条件的片段长度 { double p = a[0]; int i; for (i = 1; i < n; i++) { if (fabs(p-a[i]) < 1e-9) continue; if (p > a[i]) return 0; else if (p+d <= a[i]) p = a[i]; else p = a[i]+d; } return 1; } int main () { double Max; int T, i, k; scanf("%d", &T); while (T--) { scanf("%d", &n); for (i = 0; i < n; i++) scanf("%lf", &a[i]); memset(b, 0, sizeof(b)); Max = -INF; k = 0; sort(a, a+n); for (i = 1; i < n; i++) { b[k++] = a[i]-a[i-1]; b[k++] = (a[i]-a[i-1])/2; } for (i = 0; i < k; i++) { if (Judge(b[i])) Max = max(Max, b[i]); } printf("%.3f\n", Max); } return 0; }
HDU 4932 Miaomiao's Geometry(BestCoder Round #4)
标签:
原文地址:http://www.cnblogs.com/syhandll/p/4898322.html