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>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<pair<long long, int>> v(n);
for (auto &p : v) {
cin >> p.first >> p.second;
}
sort(v.begin(), v.end());
long long ans = numeric_limits<long long>::min();
long long s = 0;
for (int i = 0; i < n; ++i) {
s += v[i].second;
long long curr = s - (v[i].first - v[0].first);
ans = max(ans, curr);
}
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... |