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() {
int n; cin>>n;
vector<pair<ll,ll>> art(n);
for (int i=0; i<n; i++) {
cin>>art[i].first>>art[i].second;
}
sort(art.begin(), art.end());
vector<ll> pf(n);
pf[0]=art[0].second;
for (int i=1; i<n; i++) {
pf[i]=pf[i-1]+art[i].second;
}
ll ans=0;
for (int i=0; i<n; i++) {
for (int j=i+1; j<n; j++) {
ll k;
if (i==0) k=0ll;
else k=pf[i-1];
ans=max(ans, pf[j]-k-(art[j].first-art[i].first));
}
}
cout<<ans;
return 0;
}
# | 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... |