Untitled
unknown
plain_text
a month ago
734 B
0
Indexable
Never
#include <bits/stdc++.h> #define maxn 102 using namespace std; int x[maxn], y[maxn], n; int main(){ cin >> n; x[101] = 1000000009; y[101] = 1000000009; for ( int i = 1; i <= n; i++) cin >> x[i] >> y[i]; for ( int i = 1; i <= n - 1; i++) for ( int j = i + 1; j <= n; j++) if ( x[i] > x[j] ) swap(x[i], x[j]); for ( int i = 1; i <= n - 1; i++) for ( int j = i + 1; j <= n; j++) if ( x[i] == x[j] ) { if ( y[i] > y[j] ) { swap(y[i], y[j]); swap(x[i], x[j]); } } int mid = y[ n / 2 + 1]; int tong = 0; for ( int i = 1; i <= n; i++) tong += abs( y[i] - mid ); cout << tong; }
Leave a Comment