Skip to content

Commit

Permalink
Add Problem 070
Browse files Browse the repository at this point in the history
  • Loading branch information
E869120 committed Jun 18, 2021
1 parent fdbd786 commit aa7c2f2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions sol/070.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> X(N), Y(N);
for (int i = 0; i < N; ++i) {
cin >> X[i] >> Y[i];
}
nth_element(X.begin(), X.begin() + N / 2, X.end());
nth_element(Y.begin(), Y.begin() + N / 2, Y.end());
long long ans = 0;
for (int i = 0; i < N; ++i) {
ans += abs(X[i] - X[N / 2]);
ans += abs(Y[i] - Y[N / 2]);
}
cout << ans << endl;
return 0;
}

0 comments on commit aa7c2f2

Please sign in to comment.