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 ll long long
#define f first
#define s second
const int N=5e5+10;
using namespace std;
int n;
pair<ll,ll>p[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1; i<=n; i++) cin>>p[i].f>>p[i].s;
sort(p+1,p+n+1);
for(int i=1; i<=n; i++) p[i].s+=p[i-1].s;
ll mn=-p[1].f,res=0;
for(int i=1; i<=n; i++)
{
res=max(res,-p[i].f+p[i].s-mn);
mn=min(mn,-p[i+1].f+p[i].s);
}
cout<<res;
}
# | 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... |