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 maxn 500010
#define ll long long
#define pll pair<ll, ll>
vector<pll> stuff;
int N;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
ll a, b;
for (int i = 0; i < N; i++) {
cin >> a >> b;
stuff.push_back(pll(a, b));
}
sort(stuff.begin(), stuff.end());
ll ans = 0LL;
ll cbest = 0;
ll lastval = stuff[0].first;
ll cspot, cnum;
for (int i = 0; i < N; i++) {
cspot = stuff[i].first;
cnum = stuff[i].second;
cbest = max(cnum, cnum + cbest - (cspot - lastval));
lastval = cspot;
ans = max(ans, cbest);
}
cout << ans << endl;
}
# | 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... |