안테나
1. Python
n = int(input())
data = list(map(int, input().split()))
data.sort()
print(data[(n - 1) // 2])
규칙 없이 각각 계산
n = int(input())
house = list(map(int,input().split()))
house.sort()
a = house[(house - 1) // 2]
b = house[(house + 1) // 2]
distance_a = 0
distance_b = 0
for h in house:
distance_a += abs(a - h)
distance_b += abs(b - h)
if distance_a <= distance_b:
print(a)
else:
print(b)
2. C++
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
int main(void) {
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
cout << v[(n - 1) / 2] << '\n';
}