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;
typedef long long ll;
int main() {
ios::sync_with_stdio(0);
cout.tie(0);
cin.tie(0);
ll n;
cin >> n;
vector<pair<ll, ll>> v(n);
for(auto& i : v) {
cin >> i.first >> i.second;
}
sort(v.begin(), v.end());
ll ans = 0;
for(ll i = 0; i < n; i++) {
ll sum = v[i].second;
for(ll j = i + 1; j < n; j++) {
sum += v[j].second;
ans = max(ans, sum - (v[j].first - v[i].first));
}
}
cout << ans;
}
# | 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... |