您的位置:首页 > 大数据 > 人工智能

2014 Multi-University Training Contest 2

2014-07-26 09:35 309 查看
官方解题报告:http://blog.sina.com.cn/s/blog_a19ad7a10102uyet.html

ZCC Loves Intersection

#include<cstdio>
#include<algorithm>
using namespace std;
typedef __int64 LL;
const int M=100010;
struct G{
int t,k;
friend bool operator <(G a,G b){
return a.t*b.k<a.k*b.t;
}
}g[M];
int main(){
int n;
while(~scanf("%d",&n)){
for(int i=0;i<n;i++){
scanf("%d",&g[i].t);
}
for(int i=0;i<n;i++){
scanf("%d",&g[i].k);
}
sort(g,g+n);
LL ans=0,tmp=0;
for(int i=0;i<n;i++){
ans+=(tmp+g[i].t)*g[i].k;
tmp+=g[i].t;
}
printf("%I64d\n",ans);
}
return 0;
}


View Code

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: