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;
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++)
{
sum=0;
for(j=i;j<=n;j++)
{
sum=sum+v[j].val;
maxi=max(maxi,sum-(v[j].sz-v[i].sz));
}
}
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... |