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 int long long
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (auto &[x, y] : a) {
cin >> x >> y;
}
sort(a.begin(), a.end());
vector<int> p({0});
for (auto [x, y] : a) {
p.push_back(p.back() + y);
}
int jv = -1;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
jv = max(jv, p[j + 1] - p[i] - (a[j].first - a[i].first));
}
}
cout << jv << endl;
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... |