1 #include<math.h> 2 #include<iostream> 3 #include<algorithm> 4 using namespace std; 5 int a[200001],b[200001],c[200001]={0}; 6 int main() 7 { 8 int n,s=0,k,i; 9 cin>>n>>k; 10 for(i=0;i<n;i++) cin>>a[i]; 11 for(i=0;i<n;i++) 12 { 13 cin>>b[i]; 14 c[i]=a[i]-b[i]>0?a[i]-b[i]:0; 15 s+=min(a[i],b[i]); 16 } 17 sort(c,c+n); 18 for(i=0;i<k;i++) s+=c[i]; 19 cout<<s<<endl; 20 }