优先赶吃单位时间内吃花快的牛...
注意大数陷阱..
#include <cstdio>
#include <algorithm>
using namespace std;
struct cow{
int di,ti;
}c[100001];
bool cmp(cow a,cow b){
return a.di*1.0/a.ti-b.di*1.0/b.ti>0;
}
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d",&c[i].ti,&c[i].di);
}
sort(c,c+n,cmp);
long long res=0,tt=0;
for(int i=0;i<n;i++){
res+=tt*c[i].di;
tt+=2*c[i].ti;
}
printf("%lld\n",res);
}