Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
852 B
1
Indexable
Never
#include<bits/stdc++.h>

using namespace std;

typedef struct point {
    int x;
    int y;
} point;

int main() {
    int n;
    cin >> n;
    point listPoint[n];
    for(int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        listPoint[i].x = a;
        listPoint[i].y = b;
    }
    point ans;
    double minD = 9999999999;
    for (int i = 0; i < n; i++) {
        double s = 0;
        for (int j =0; j < n; j++){
            if (i == j)
                continue;
            s += abs(listPoint[i].x- listPoint[j].x) + abs(listPoint[i].y- listPoint[j].y);
        }
        double avg = s/double(n-1);
        if (avg < minD) {
            minD = avg;
            ans.x = listPoint[i].x;
            ans.y = listPoint[i].y;
        }
    }
    cout << ans.x << " " << ans.y;
    return 0;
}