#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
struct data{int x,y;}a[100001];
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x*=10;x+=ch-'0';ch=getchar();}
return x*f;
}
inline bool cmp(data a,data b){return a.x*b.y<b.x*a.y;}
int n;
long long ans,t;
int main(){
n=read();
for(int i=1;i<=n;i++){
a[i].x=read();a[i].y=read();
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
ans+=t*a[i].y;
t+=a[i].x*2;
}
printf("%lld",ans);
return 0;
}
1634: [Usaco2007 Jan]Protecting the Flowers 护花
最新推荐文章于 2023-05-30 21:58:44 发布