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>
#define f first
#define s second
using namespace std;
typedef long long ll;
int main(){
int n;
cin>>n;
vector<pair<ll,ll> > a(n);
for(int i=0;i<n;i++)cin>>a[i].f>>a[i].s;
sort(a.begin(),a.end());
ll mini=-a[0].f;
ll mas=LLONG_MIN;
ll s=0;
for(int i=0;i<n;i++){
mas=max(mas,s+a[i].s-mini-a[i].f);
mini=min(mini,s-a[i].f);
s+=a[i].s;
}
cout<<mas<<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... |