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 ll long long
int n;
vector<pair<ll,ll>> v;
signed main()
{
cin >> n;
for (int i=0;i<n;i++)
{
ll x,y;
cin >> x >> y;
v.push_back({x,y});
}
sort(v.begin(),v.end());
ll lo=0;
ll sum=0;
ll res=0;
for (auto x : v)
{
lo=min(lo,sum-x.first);
sum+=x.second;
res=max(res,sum-x.first-lo);
}
cout << res;
}
# | 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... |