Submission #101274

#TimeUsernameProblemLanguageResultExecution timeMemory
101274mayhoubsalehSimfonija (COCI19_simfonija)C++14
0 / 110
114 ms2564 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; int n,k; pair<int,int>a[100005]; bool mys(pair<int,int>a,pair<int,int>b){ int x=abs(a.first-a.second); int y=abs(b.first-b.second); return x>y; } int ans=0; int main(){ cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i].first; } for(int i=0;i<n;i++){ cin>>a[i].second; } sort(a,a+n,mys); int mid1=0,mid2=0; for(int i=k;i<n;i++){ mid1+=a[i].first; mid2+=a[i].second; } int m=n-k; mid1=(double)(mid1*1.0/m+0.5); mid2=(double)(mid2*1.0/m+0.5); int x=mid1-mid2; //cout<<mid1<<' '<<mid2<<' '<<x<<endl; for(int i=k;i<n;i++){ ans+=abs(x+a[i].second-a[i].first); } cout<<ans<<endl; return 0; } //ofstream fout("planting.out"); //ifstream fin("planting.in");
#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...