比赛 |
H大佬的水题争霸赛 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
期末考试 |
最终得分 |
100 |
用户昵称 |
雾茗 |
运行时间 |
0.226 s |
代码语言 |
C++ |
内存使用 |
2.34 MiB |
提交时间 |
2018-08-04 13:10:10 |
显示代码纯文本
#include<cstdio>
#include<iostream>
typedef long long i64;
const int N=100017;
i64 A,B,C;
int n,m;
i64 s[N],s2[N],s1[N],ans=1ll<<60;
i64 min(i64 a,i64 b){
return a<b?a:b;
}
void maxs(int&a,int b){if(a<b)a=b;}
int main(){
freopen("exam_heoi2017.in","r",stdin);
freopen("exam_heoi2017.out","w",stdout);
scanf("%lld%lld%lld",&A,&B,&C);
scanf("%d%d",&n,&m);
int mx=1;
for(int i=0,x;i<n;++i){
scanf("%d",&x);
++s[x+1];
maxs(mx,x+1);
}
for(int i=0,x;i<m;++i){
scanf("%d",&x);
s2[x]+=x;
++s1[x];
maxs(mx,x);
}
for(int i=1;i<=mx;++i){
s[i]+=s[i-1];
s1[i]+=s1[i-1];
s2[i]+=s2[i-1];
}
for(int i=1;i<=mx;++i) s[i]+=s[i-1];
for(int i=1;i<=mx;++i){
i64 l=s1[i]*i-s2[i],r=s2[mx]-s2[i]-(s1[mx]-s1[i])*i;
if(1.*r*B+1.*min(l,r)*min(0,A-B)+1.*s[i]*C>ans*2)continue;
i64 z=r*B+min(l,r)*min(0,A-B)+s[i]*C;
ans=min(ans,z);
}
printf("%lld\n",ans);
return 0;
}