#include<bits/stdc++.h>
using namespace std;
int n,num;
struct pp
{
int w,v;
}a[50005];
void dfs(int x,int y)
{
if(x==n+1)
{
return;
}
num+=a[x].w-y;
y+=a[x].v;
if(a[x+1].w<=y)
{
return;
}
dfs(x+1,y);
}
int cmp(pp x,pp y)
{
if(x.v!=y.v)
{
return x.v<y.v;
}
else
{
return x.w>=y.w;
}
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].w>>a[i].v;
}
sort(a+1,a+n+1,cmp);
dfs(1,0);
cout<<num;
}
这只能过2个点
麻烦各位大佬捏个数据