题意:
有n个牛在FJ的花园乱吃。
所以FJ要赶他们回牛棚。
每个牛在被赶走之前每秒吃Di个花朵。赶它回去FJ要花的时间是Ti。在被赶走的过程中牛就不能乱吃了
题解:
每次你赶走的都是当前情况下单位时间吃的最多的牛
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <string.h>
using namespace std;
typedef pair<int ,int> p;
bool cmp(p a,p b){
return a.first * b.second < b.first * a.second;
}
int main(){
int n;
cin>>n;
p cow[100005];
long long sum = 0;
long long ans = 0;
for(int i =0;i<n;i++){
cin>> cow[i].first>>cow[i].second;
sum += cow[i].second;
}
sort(cow,cow+n,cmp);
for(int i = 0;i<n;i++){
sum -= cow[i].second;
ans += sum *cow[i].first*2;
}
cout<<ans<<endl;
}