#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define pb push_back
#define ertunt return
#define vodka void
using namespace std;
int main(){
ll n;
cin >> n;
pair<ll,ll> a[n+4];
for(ll i = 1; i <= n; i++)cin >> a[i].ff >> a[i].ss;
sort(a+1,a+n+1);
ll b[n+4] = {0};
for(ll i = 1; i <= n; i++){
b[i] = b[i-1]+a[i].ss;
}
ll ans = 0;
for(ll i = 1; i <= n; i++){
for(ll j = i+1; j <= n; j++){
ans=max(ans,b[j] - b[i-1] - a[j].ff + a[i].ff);
}
}
cout << ans << ' ';
}
# | 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... |