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;
struct ceva
{
long long sz,val;
}v[500010];
bool cmp(ceva a,ceva b)
{
return a.sz<b.sz;
}
long long n,i,sum,maxi,j,p[500010],pre=LLONG_MAX;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
cin>>v[i].sz>>v[i].val;
sort(v+1,v+n+1,cmp);
for(i=1;i<=n;i++)
{
p[i]=p[i-1]+v[i].val;
pre = min(pre, p[i-1]-v[i].sz);
maxi=max(maxi,p[i]-v[i].sz-pre);
}
cout<<maxi;
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... |