#include<bits/stdc++.h>
using namespace std;
int main (){
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long n;
cin >> n;
vector<pair<long long,long long>> a(n);
for(int i=0; i<n; i++) cin >> a[i].first >> a[i].second;
sort(a.begin(), a.end());
long long res=0, l=0, tong=0;
for(int r=0; r<n; r++){
tong+=a[r].second;
long long amin=a[l].first;
long long amax=a[r].first;
long long ok= tong - (amax - amin);
res=max(res,ok);
}
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... |