hdu 4882 ZCC Loves Codefires(贪心)
Posted yutingliuyl
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 4882 ZCC Loves Codefires(贪心)相关的知识,希望对你有一定的参考价值。
# 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(贪心)的主要内容,如果未能解决你的问题,请参考以下文章
HDU 4879 ZCC loves march (并查集,set,map)
HDU 5228 ZCC loves straight flush( BestCoder Round #41)
HDU 4876 ZCC loves cards 暴力+剪枝