比赛 2026郑轻校赛 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 卖货 最终得分 100
用户昵称 dream 运行时间 0.866 s
代码语言 C++ 内存使用 6.48 MiB
提交时间 2026-04-07 19:01:29
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
int n,k,kk;
ll a[N],b[N];
struct node{
	ll x,y;
	bool operator <(const node &t) const{
		return abs(x-y)>abs(t.x-t.y);
	}
}c[N];
ll ans;
int main(){
	freopen("sale.in","r",stdin);
	freopen("sale.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],c[i].x=a[i];
	for(int i=1;i<=n;i++) cin>>b[i],c[i].y=b[i];
	cin>>k;
	kk=n-k;
	sort(c+1,c+n+1);
	for(int i=1;i<=n;i++){
		if(!k) ans+=c[i].y;
		else if(!kk) ans+=c[i].x;
		else{
			if(c[i].x>c[i].y){
				k--;
				ans+=c[i].x;
			}
			else{
				kk--;
				ans+=c[i].y;
			}
		}
	}
	cout<<ans;
 	return 0;
}