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;
typedef long long ll;
int main(){
ll n, m;
cin >> n >> m;
ll a[m];
for (ll i = 2; i <= n + m; i ++){
ll p;
cin >> p >> a[i - 2];
}
ll res = 1e18;
for (ll i = 0; i < m; i ++){
ll ans = 0;
for (ll j = 0; j < m; j ++){
ans += abs(a[i] - a[j]);
}
res = min(res, ans);
}
cout << res << endl;
}
# | 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... |