标签:hdu 4882 多校 namespace dfs amp
# include<stdio.h> # include <algorithm> # include <string.h> using namespace std; struct node { int v; int t; }; struct node a[100010]; bool cmp(node a,node b) { return a.v *a.t+(a.v+b.v)*b.t<b.v*b.t+(a.v+b.v)*a.t; } int main() { int n; __int64 sum; int i; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf("%d",&a[i].v); for(i=0;i<n;i++) scanf("%d",&a[i].t); sort(a,a+n,cmp); __int64 sum1=0; sum=0; for(i=0;i<n;i++) { sum = (a[i].v+sum); sum1+=sum*a[i].t; } printf("%I64d\n",sum1); } return 0; }
hdu 4882 ZCC Loves Codefires(贪心),布布扣,bubuko.com
hdu 4882 ZCC Loves Codefires(贪心)
标签:hdu 4882 多校 namespace dfs amp
原文地址:http://blog.csdn.net/lp_opai/article/details/38090867