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 ll long long
#define f first
#define sc second
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,maxx,maxx1;
pair <ll,ll> A[500005];
int main() {
cin>>n;
for(ll i=1;i<=n;i++) {
cin>>A[i].f>>A[i].sc;
}
sort(A+1,A+1+n);
for(ll i=1;i<=n;i++) {
a+=A[i].sc;
maxx1=max(maxx1,-(a-A[i].sc)+A[i].f);
maxx=max(maxx,a-A[i].f+maxx1);
//cout<<a<<" "<<maxx1<<" "<<maxx<<endl;
}
cout<<maxx;
}
# | 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... |