#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int N = 100100;
vector<int> qr;
int n, k, a[N], b[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int j = 0; j < n; j++){
cin >> b[j];
qr.PB(a[j] - b[j]);
}
ll ans = 0;
sort(all(qr));
ll cur = qr[n / 2];
for (int i = 0; i < n; i++)
ans += abs(a[i] - cur - b[i]);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
3104 KB |
Output is correct |
2 |
Correct |
35 ms |
3072 KB |
Output is correct |
3 |
Correct |
36 ms |
3072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
3072 KB |
Output is correct |
2 |
Correct |
38 ms |
3072 KB |
Output is correct |
3 |
Correct |
33 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
3072 KB |
Output is correct |
2 |
Correct |
37 ms |
3072 KB |
Output is correct |
3 |
Correct |
35 ms |
3072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
2432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
3068 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
3072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |