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;
#define int long long
#define ar array
#define db double
const int mxn=5e5+3;
int n;
ar<int,2> a[mxn];
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i][0]>>a[i][1];
sort(a+1,a+n+1);
int ans=0;
// n^2
for (int i=1;i<=n;i++)
{
int sum=0;
for (int j=i;j<=n;j++)
{
sum+=a[j][1];
ans=max(ans,sum-(a[j][0]-a[i][0]));
}
}
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... |