#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
#define vel vector<long long>
#define V vector
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int pr = 1000000007;
void uni(vel &a) {
vel ans(1, a[0]);
int n = a.size();
rep(i, n - 1) { if (a[i + 1] != a[i]) { ans.push_back(a[i + 1]); } }
a = ans;
}
int rui(int a, int n) {
if (n == 0) { return 1; }
int back = rui(a, n / 2);
back *= back; back %= pr;
if (n % 2 == 0) { return back; }
return (back*a) % pr;
}
int inv(int a) {
return rui(a, pr - 2);
}
signed main() {
int n, m; cin >> n >> m;
vel c(m);
rep(i, m) {
int q; cin >> q;
cin >> c[i];
}
sort(c.begin(),c.end());
int mid = c[n / 2];
int ans = 0;
rep(i, n) { ans += abs(c[i] - mid); }
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |