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<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main()
{
vector<pair<int,int>> arta; int n; ll a,b; cin >> n;
for(int i = 1; i <= n ; i++)
{
cin >> a >> b;
arta.push_back({a,b});
}
sort(arta.begin(),arta.end()); ll suma = arta[0].second;
ll minim = -arta[0].first,ans = -1e18,last = suma;
for(int i = 1; i < n ; i++)
{
suma += arta[i].second;
ans = max(ans,suma - arta[i].first - minim);
minim = min(minim,last - arta[i].first);
last = suma;
}
cout << ans;
}
# | 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... |