This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
* created by Mohamed hossam
#### #### ## ##
## ## ## ## ##### ## ## ###### ##
## ## ## ## ## ## ####### ############## ## ## ########
## ###### ## ## ## ####### ############## ######### ## ##
## ## ## ## ## ## ## ## ## ## ## ##
### ### ##### ## ## ## ## ## ####### ########
*/
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
fast;
ll n;
cin>>n;
pair<ll,ll>a[n];
for(ll i=0; i<n; i++)
{
cin>>a[i].first>>a[i].second;
}
/*
1 5
4 1
4 2
5 3
9 1
10 3
*/
sort(a,a+n);
ll k=0,x=-1,z=0;
for(ll i=0; i<n; i++)
{
k+=a[i].second;
x=max(x,k-(a[i].first-a[0].first));
z=max(z,a[i].second);
}
k=0;
for(ll i=n-1; i>=0; i--)
{
k+=a[i].second;
x=max(x,k-(a[n-1].first-a[i].first));
}
cout<<max(x,z);
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... |