//在a数组上进行k1次操作,在b数组上进行k2次操作 操作必须全部完成
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000+5;
typedef long long LL;
LL a[maxn],b[maxn];
int main()
{
int n,k1,k2;
scanf("%d%d%d",&n,&k1,&k2);
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
priority_queue<LL>pq; //大顶堆
while(!pq.empty()) pq.pop();
k1+=k2; //总操作数
for(int i=0;i<n;i++)
{
pq.push((LL)abs((a[i]-b[i])));
}
while(k1--)
{
LL x=pq.top();
pq.pop();
x--;
if(x<0) x=-x;
pq.push(x);
}
LL ans=0;
while(!pq.empty())
{
LL x=pq.top();
pq.pop();
ans+=x*x;
}
cout<<ans<<endl;
return 0;
}
Codeforces Divide by Zero 2018 and Codeforces Round #474 (Div. 1 + Div. 2, combined) B 贪心
猜你喜欢
转载自blog.csdn.net/m0_37428263/article/details/79912447
今日推荐
周排行