Submission #116791

#TimeUsernameProblemLanguageResultExecution timeMemory
116791ioilolcomSimfonija (COCI19_simfonija)C++14
44 / 110
57 ms2960 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" typedef long long int ll; vector<int>a,b,c; int main() { ios_base:: sync_with_stdio(false); cin.tie(0); int n; cin>>n; int k; cin>>k; c.resize(n+1); a.resize(n+1); b.resize(n+1); for(int i=1; i<=n; i++) { cin>>a[i]; } for(int i=1; i<=n; i++) { cin>>b[i]; c[i]=a[i]-b[i]; } sort(c.begin()+1,c.end()); int m=c[n/2+(n%2)]; ll sum=0; for(int i=1; i<=n; i++) { sum+=abs(c[i]-m); c[i]=abs(c[i]-m); } sort(c.begin(),c.end()); for(int i=1; i<=k; i++) { if(!c.size()) break; sum-=c.back(); c.pop_back(); } cout<<sum<<endl; 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...