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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
vector <pair <ll, ll>> pnts;
int main() {
int n;
cin >> n;
pnts.resize(n);
for (int i = 0; i < n; i++)
cin >> pnts[i].first >> pnts[i].second;
sort(pnts.begin(), pnts.end());
ll ans = 0;
for (int i = 0; i < n; i++) {
ll tot_val = 0;
for (int j = i; j < n; j++) {
tot_val += pnts[j].second;
ans = max(ans, tot_val - (pnts[j].first - pnts[i].first));
}
}
cout << ans << '\n';
}
# | 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... |