tjut 4310

来源:互联网 发布:10月份经济数据2017 编辑:程序博客网 时间:2024/05/17 04:06
#include<iostream>#include<algorithm>using namespace std;struct Dota{    double DPS;    double HP;}hero[50];bool cmp(Dota h1,Dota h2){    return h1.DPS/h1.HP>h2.DPS/h2.HP;}int main(){    int n,i;    __int64 sum,total;    while(~scanf("%d",&n))    {        total=0;        for(i=0;i<n;i++)        {            scanf("%lf %lf",&hero[i].HP,&hero[i].DPS);//质疑先输入血量还是伤害值?            total+=hero[i].DPS;        }        sort(hero,hero+n,cmp);        sum=0;        for(i=0;i<n;i++)        {            sum+=hero[i].HP*total;            total-=hero[i].DPS;        }        printf("%I64d\n",sum);    }    return 0;}

0 0