#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define pii pair <int,int>
#define r0 return 0
using namespace std;
const int N = 5 * 1e5 + 5;
int x,m,k,n,l,r,ans,cheese;
int pref[N],p[N],mn;
pii a[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].ff >> a[i].ss;
}
sort(a + 1,a + 1 + n);
p[0] = -a[1].ff;
pref[0] = 0;
for (int i = 1; i <= n; i++){
pref[i] = pref[i - 1] + a[i].ss;
p[i] = min(p[i - 1],pref[i] - a[i].ff);
}
k = -LLONG_MAX;
for (int i = 1; i <= n; i++) {
k = max(k,pref[i] - a[i].ff - p[i - 1]);
}
cout << k << endl;
r0;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:32:10: error: 'LLONG_MAX' was not declared in this scope
32 | k = -LLONG_MAX;
| ^~~~~~~~~
art.cpp:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
4 | #include <map>
+++ |+#include <climits>
5 | #define int long long