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 ff first
#define ss second
using namespace std;
using ll = long long;
ll n;
vector<pair<ll, ll>> a;
int main(){
cin >> n;
for(int i = 0; i < n; i++){
int x, y;
cin >> x >> y;
a.push_back({x, y});
}
sort(a.begin(), a.end());
ll best = 0, cur = 0;
for(ll i = 0; i < n; i++){
cur += a[i].ss;
cur = max(cur, a[i].ss + a[i].ff);
best = max(best, cur - a[i].ff);
}
cout << best;
}
# | 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... |