Main topic:
give you the n number of five-dimensional coordinates, you want to ask any two points between the maximum distance between Manhattan;
Ideas:
For points I and J: Manhattan Distance: |x1-x2|+|y1-y2|+ ...
Remove the absolute value (+-x1+-y1 ...) -(+-x2+-y2 ...) and the corresponding position plus minus sign is the same
So for five-dimensional coordinates, there's a 2^5 of possibilities.
The enumeration then evaluates the maximum value
#include <cstdio>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
Double s[100009][6];
int main ()
{
int n;
scanf ("%d", &n);
for (int. i=0; i<n; i++) for
(int j=0; j<5; j + +) scanf ("%lf", &s[i][j]);
Double ans=0;
for (int i=0; i< (1<<5); i++)//Enumerate each of the possible
{
double minn=inf,maxn=-inf;
for (int j=0; j<n; j + +)//calculates the value of each number
{
double t=0;
for (int k=0; k<5; k++)
{
if ((1<<k) &i) t+=s[j][k];//uses bit operations to enumerate
else t-=s[j][k];
}
Minn=min (minn,t);
Maxn=max (maxn,t);
}
Ans=max (ans, (Maxn-minn));//This is the maximum value in the case of the former I
}
printf ("%.2f\n", ans);
return 0;
}