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 int
void solve() {
int n, ans = 0;
cin >> n;
vector<pair<int, int>> a(n);
for (auto &x : a) {
cin >> x.first >> x.second;
}
sort(a.begin(), a.end());
for (int i = 0; i < n; i++) {
int s = 0;
for (int j = i; j < n; j++) {
s += a[j].second;
ans = max(ans, s-abs(a[i].first-a[j].first));
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
t = 1;
while(t--) {
solve();
}
}
# | 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... |