结束2分钟后调好的,也不知道能不能完全通过
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;
int n;
long long x[50];
long long y[50];
int test()
{
long long min_x = 1000000000, min_y = 1000000000, max_x = 0, max_y = 0;
for (int i = 0; i < n; i++)
{
if (x[i] < min_x)
min_x = x[i];
if (y[i] < min_y)
min_y = y[i];
if (x[i] >max_x)
max_x = x[i];
if (y[i] > max_y)
max_y = y[i];
}
vector<long long> min1(n,1000000000);
int num = 0;
for (int _x = min_x; _x <=max_x; _x++)
{
for (int _y = min_y; _y <=max_y; _y++)
{
vector<long long> dist(n);
for (int k = 0; k < n; k++)
{
dist[k] = abs(_x - x[k]) + abs(_y - y[k]);
}
std::sort(dist.begin(), dist.end(), less<int>());
for (int k = 1; k < n; k++)
{
dist[k] = dist[k] + dist[k-1];
}
for (int k = 0; k < n; k++)
{
min1[k] = min(min1[k],dist[k]);
}
}
}
for (int i = 0; i < n; i++)
cout << min1[i];
return 1;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i];
for (int i = 0; i < n; i++)
cin >> y[i];
test();
return 0;
}