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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr first
#define sc second
const int mxn=5e5+5;
int n;
pair<ll ,ll >a[mxn];
set<ll >s;
ll lazy=0;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].fr>>a[i].sc;
}
sort(a+1,a+n+1);
s.insert(a[1].sc);
ll ans=a[1].sc;
for(int i=2;i<=n;i++){
lazy+=a[i].sc;
lazy-=a[i].fr-a[i-1].fr;
s.insert(a[i].sc-lazy);
ll x=*s.rbegin();
ans=max(ans,x+lazy);
}
cout<<ans;
return 0;
}
# | 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... |