标签:bool i++ lov pos post ring can scan data
# 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(贪心)
标签:bool i++ lov pos post ring can scan data
原文地址:http://www.cnblogs.com/yutingliuyl/p/7074487.html