#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
pair<long long,long long>a[n+1];
for(int i=1;i<=n;i++)
{
cin>>a[i].first>>a[i].second;
}
sort(a+1,a+n+1);
long long ma=LLONG_MIN;
long long mb=LLONG_MIN;
long long cnt=0;
for(int i=01;i<=n;i++)
{
ma=max(ma,a[i].first-cnt);
cnt+=a[i].second;
mb=max(mb,cnt-a[i].first+ma);
}
cout<<mb<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |