This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, M;
ll X[100005];
ll Y[100005];
int main() {
cin.tie(0) -> sync_with_stdio(false);
cin >> N >> M;
for(int i = 0; i < M; i++) {
cin >> X[i] >> Y[i];
}
sort(X, X + M);
sort(Y, Y + M);
ll x = X[M / 2], y = Y[M / 2];
ll ans = 0;
for(int i = 0; i < M; i++) {
ans += abs(x - X[i]);
ans += abs(y - Y[i]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |