#include<iostream>
#include<algorithm>
using namespace std;
struct test
{
int id;
int time;
int tired;
}t[200000];
bool cmp(test x,test y)
{
if(x.tired==y.tired)
{
return x.time<y.time;
}
return x.tired>y.tired;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int a,b;
cin>>a>>b;
t[i].id=i;
t[i].time=a;
t[i].tired=b;
}
sort(t+1,t+n+1,cmp);
long long ans=0;
for(int i=1;i<=n;i++)
{
int tmp=0;
for(int j=i+1;j<=n;j++)
{
tmp=tmp+t[j].tired;
}
ans=ans+tmp*t[i].time;
}
cout<<ans<<endl;
return 0;
}
问下大佬们D题这样做为什么A不了呢?