BC A question to do when you want to go to the game and didn't think of any example of the result is a floating point value so the output I used the most upright. 000 now, think about it.
Test instructions: Give you a lot of points on the line now requires the same length of line to cover all the points on this side there are two requirements that these points can only be covered by the two endpoints of the segment 22 segments cannot intersect (remove the endpoint) ask the maximum number of line segments that satisfy the condition
Problem-solving ideas: first to order all the points from small to large and then record the difference between the two points and the difference between the half and then just go to fill to see if the condition is satisfied to find the maximum value my side is directly using the set to exclude all duplicate values and from large to small to determine the satisfaction of the direct break
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <set> #
Include<vector> #include <algorithm> using namespace std;
#define EPS 1e-8 set<double> s;
Double num[60];
int n;
BOOL Judge (double val) {bool last = false;
for (int i = 1;i < n-1;i++) {if (!last && num[i]-num[i-1] >= val) last = false;
else if (last && fabs (num[i-1] + val-num[i]) = = 0) last = false;
else if (last && num[i]-num[i-1] – 2*val >= 0) last = false;
else if (num[i + 1]-num[i] >= val) last = true;
else return false;
} return true;
} int main () {int T;
scanf ("%d", &t);
while (t--) {scanf ("%d", &n);
for (int i = 0;i < n;i++) scanf ("%lf", &num[i]);
Sort (num,num + N);
S.clear ();
for (int i = 1;i < n;i++) {S.insert (Num[i]-num[i-1]); S.insert ((Num[i]-NUM[I-1])/2.0);
} double ans = 0.000;
Set<double>::iterator it;
for (it = s.end (); It! = S.begin (); it--) {if (judge (*it)) {ans = *it;
Break
}} printf ("%0.3lf\n", ans);
} return 0; }