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;
int main(){
int n;
cin>>n;
vector<pair<long long,long long> >v;
long long mn=LLONG_MAX,mx=0;
for(int i=0;i<n;i++){
long long a,b;
cin>>a>>b;
v.push_back({a,b});
if(a<mn){
mn=a;
}
}
sort(v.begin(),v.end());
long long sum=0;
for(int i=0;i<n;i++){
sum+=v[i].second;
if(sum-(v[i].first-mn)>mx){
mx=sum-(v[i].first-mn);
}
}
cout<<mx;
}
# | 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... |