This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const int N = 5e5 + 5;
pair<ll, ll> a[N];
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].f >> a[i].s;
}
sort(a, a + n);
ll x = a[0].f, y = a[0].s;
for (int i = 1; i < n; i++) {
a[i].s += a[i - 1].s;
x = max(x, a[i].f - a[i - 1].s);
y = max(y, a[i].s - a[i].f + x);
}
cout << y << "\n";
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... |