Submission #225062

#TimeUsernameProblemLanguageResultExecution timeMemory
225062VEGAnnSimfonija (COCI19_simfonija)C++14
44 / 110
50 ms3064 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...