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 <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n;
vector<pair<ll,ll>>v;
int main()
{
cin>>n;
v.resize(n);
for(int i=0;i<n;i++)
{
cin>>v[i].first>>v[i].second;
}
sort(v.begin(),v.end());
ll ans=v[0].second;
ll mini=v[0].first;
ll tValue=v[0].second;
ll ans2=0;
for(int i=1;i<n;i++)
{
tValue+=v[i].second;
ll maxx=v[i].first;
ans2=tValue-(maxx-mini);
if(ans2>ans)ans=ans2;
}
cout<<ans;
return 0;
}
# | 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... |