提交时间:2023-08-09 16:57:59
运行 ID: 81613
#include<bits/stdc++.h> using namespace std; int n,b[100001],ans=0,sum[100001],x; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x>>b[i]; b[i]=b[i]*1000+x; } sort(b+1,b+n+1); for(int i=1;i<=n;i++){ sum[i]=sum[i-1]+b[i]%1000; if(sum[i-1]<b[i]/1000) ans=max(ans,b[i]/1000-sum[i-1]); } cout<<ans+sum[n]; return 0; }