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 int long long
main(){
int n;
cin>>n;
vector<pair<int,int> >v2,v;
int sum = 0;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
v2.push_back(make_pair(a,b));
}
sort(v2.begin(),v2.end());
v.push_back(make_pair(0,0));
for(int i=0;i<n;i++){
sum+=v2[i].second;
v.push_back(make_pair(v2[i].first,sum));
}
int ans =0;
int maxi = -1e9;
for(int i=1;i<=n;i++){
maxi = max(maxi,v[i].first-v[i-1].second);
ans = max(ans,v[i].second-v[i].first+maxi);
}
cout<<ans;
}
Compilation message (stderr)
art.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){
| ^~~~
# | 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... |