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 int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
int n;
cin>>n;
vector <pair <int,int> > v(n);
for(int i=0;i<n;i++){
cin>>v[i].ff>>v[i].ss;
}
sort(all(v));
int mx=0;
int sum=0;
int res=0;
for(int i=0;i<n;i++){
mx=max(-sum+v[i].ff,mx);
sum+=v[i].ss;
res=max(res,sum-v[i].ff+mx);
}
cout<<res<<"\n";
}
# | 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... |