HDU 4310 Greed

Source: Internet
Author: User

Your DPS in the game is 1 but HP gives you an unlimited number of n enemies DPS and HP you can destroy an enemy in one second. Your DPS hp when you output all the living enemies will hit you to kill all enemies when you drop the least HP

Start thinking wrong sort of time first deal with DPS higher then WA

Even in the game this is very silly.

Should deal with dps/hp higher if put in the game should be first kill the output ability weak ...

If the direct return A.DPS/A.HP>B.DPS/B.HP will appear decimal

So use return A.DPS*B.HP>B.DPS*A.HP

#include <stdio.h> #include <string.h> #include <algorithm> #include <map> #include <math.h >using namespace Std;struct node{    long Long int dps;    Long long int hp;}; Node A[25];int CMP (node A,node b) {    return a.dps*b.hp>b.dps*a.hp;} int main () {int n;while (~scanf ("%d", &n)) {    long long int sum=0;    for (int i=1;i<=n;i++)    {        scanf ("%i64d%i64d", &a[i].dps,&a[i].hp);        Sum+=a[i].dps;    }    Sort (a+1,a+1+n,cmp);    Long long int ans=0;    for (int i=1;i<=n;i++)    {        ans+=sum*a[i].hp;        Sum-=a[i].dps;    }    printf ("%i64d\n", ans);}}

  

HDU 4310 Greed

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.