#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define harderahhh ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int N = 1000000007;
using namespace std;
ll x, l, y, t, z, hp, sus1, sus2, g, sus, sus3, bruh, bruh1, bruh2, bruh3, dog1, h, r, dog2, dog3, ck, ck1, ck2, ck3, dog, i, p, j, q, m, a[696969], b[696969], c[696969], n, k, d[696969], e[696969], x1[696969], x2[696969], joy[1005][1005], pp[1005][1005];
string s1, s2, s3, s4, s5, s6, s7, s8, s9, rep1, rep2, rep3, rep, s, hsr[696969];
char c1, c2, oon, hi[1005][1005], na[1005][1005], cc[696969];
pair <ll, ll> goku[696969];
vector <ll> aag[200005], eeg[200005], ski, bidi;
map <ll, ll> mm;
bool vis[200005];
int main() {
harderahhh;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> goku[i].ff >> goku[i].ss;
}
sort (goku+1, goku+n+1);
a[1] = goku[1].ss;
a[0] = 0;
for (i = 2; i <= n; i++) {
a[i] = goku[i-1].ff - goku[i].ff + goku[i].ss;
}
for (i = 1; i <= n; i++) {
a[i] = a[i-1]+a[i];
}
ll cur = 0 ;
ll ans = 0;
for(ll i = 0; i <= n; i++){
ans = max(ans, a[i] - cur);
cur = min(cur,a[i]);
if(i != 0)ans = max(ans,goku[i].ss);
}
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... |