题目: http://acm.hdu.edu.cn/showproblem.php?pid=4310
#include<iostream>
#include <stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node{int dps;int hp;friend booloperator<(constnode a,const node b){return a.dps* b.hp - b.dps * a.hp > 0;}
}hero[25];
int main(){int n,i,j;while(~scanf("%d",&n)){for(i =0;i < n;i++)scanf("%d%d",&hero[i].dps,&hero[i].hp);sort(hero, hero+n);int ans =0;for(i =0;i <n;i++){int sum = 0;for(j = i;j <n;j++)sum += hero[j].dps;sum *=hero[i].hp;ans+=sum;}printf("%d\n",ans);}return 0 ;
}