#include <iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<math.h>
#define int long long
const int inf = 1e17;
const int maxn = 300005;
const int mod = (int)1e9 + 7;
using namespace std;
int32_t main()
{
int n, m; cin >> n >> m;
vector<int> a;
for (int i = 1; i < (n + m); ++i) {
int x, y; cin >> x >> y;
a.push_back(y);
}
sort(a.begin(), a.end());
int ans = 0;
for (auto x : a)
ans += abs(x - a[a.size() / 2]);
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... |