This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<algorithm>
#define endl '\n'
using namespace std;
long long n,pref=0,s,maxr=0,mi=0,ma=0;
pair<long long,long long> p[500005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=0;i<n;i++)
cin>>p[i].first>>p[i].second;
sort(p,p+n);
for(int i=0;i<n;i++)
{
mi=max(mi,p[i].first-pref);
pref+=p[i].second;
maxr=max(maxr,mi+pref-p[i].first);
}
cout<<maxr<<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... |