#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 ll N = 100100;
vector<ll> qr;
ll n, k, a[N], b[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> k;
for (ll i = 0; i < n; i++)
cin >> a[i];
for (ll 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];
qr.clear();
for (ll i = 0; i < n; i++)
qr.PB(abs(a[i] - cur - b[i]));
sort(all(qr));
for (ll it = 0; it + k < n; it++)
ans += qr[it];
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
2804 KB |
Output is correct |
2 |
Correct |
44 ms |
2804 KB |
Output is correct |
3 |
Correct |
36 ms |
2812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
2812 KB |
Output is correct |
2 |
Correct |
42 ms |
2812 KB |
Output is correct |
3 |
Correct |
36 ms |
2812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
2804 KB |
Output is correct |
2 |
Correct |
42 ms |
3064 KB |
Output is correct |
3 |
Correct |
37 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2812 KB |
Output is correct |
2 |
Correct |
36 ms |
2804 KB |
Output is correct |
3 |
Incorrect |
39 ms |
2684 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
2812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
2812 KB |
Output is correct |
2 |
Incorrect |
39 ms |
2812 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
2812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
2812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
2824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |