#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<pair<ll, ll>> p(n + 1);
vector<ll> psum(n + 1); psum[0] = 0;
for (int i = 1; i <= n; i++) {
cin >> p[i].first >> p[i].second;
}
sort(p.begin(), p.end());
for (int i = 1; i <= n; i++) {
psum[i] = p[i].second + psum[i - 1];
}
ll ans = 0;
for (int i = 1, l = 0; i <= n; i++) {
for (int j = 1; j <= i; j++) {
ans = max(ans, psum[i] - psum[j - 1] - (p[i].first - p[j].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... |