题意:
有三个数组,a,b,c。从三个数组中,分别取出一个数,得到的三个数x, y, z,使得(x-y)^2+(x-z)^2 + (y-z)^2最小。
输入:样例个数T,三个数组的大小,na,nb,nc。之后三行是桑数组的元素。
思路:
对三个数组进行排序,然后进行依次的遍历。但是不是暴力的遍历,暴力肯定会超时。因为每次必须从三个数组中分别取出一个,所以,设a,b,c三个数组的当前元素的下标为i, j, k,枚举三种情况,i+1, j+1, k+1.算出最小值,然后更新最终答案。
#pragma warning(disable:4996)
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 100005;
const ll inf = 4e18;
ll a[N], b[N], c[N];
ll calc(ll t1, ll t2, ll t3)
{
return (t1 - t2)*(t1 - t2) + (t2 - t3)*(t2 - t3) + (t1 - t3)*(t1 - t3);
}
int mai