ac

逸尘  •  1年前


include<bits/stdc++.h>

using namespace std; struct classmate{

int y,c;	

}; bool cmp(classmate x,classmate y){

return x.c+x.y<y.c+y.y;

} int main(){

int n,ans=0,zyxl=0;
cin>>n;
classmate a[n+5];
for(int i=1;i<=n;i++){
	cin>>a[i].y>>a[i].c;
}	
sort(a+1,a+1+n,cmp);
ans-=a[1].c;
for(int i=2;i<=n;i++){
	zyxl+=a[i-1].y;
	ans=max(ans,zyxl-a[i].c);
}
cout<<ans;
return 0;

}


评论:

请先登录,才能进行评论