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;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<long long, long long>>arts(n + 1);
for(int i = 1;i <= n;++i){
cin >> arts[i].first >> arts[i].second;
}
sort(arts.begin(), arts.end());
vector<long long>pref(n + 1);
for(int i = 1;i <= n;++i){
pref[i] = pref[i - 1] + arts[i].second;
}
long long mx = 0;
for(int i = 1;i <= n;++i){
for(int j = i;j <= n;++j){
long long a_max = arts[j].first, a_min = arts[i].first;
long long S = pref[j] - pref[i - 1];
mx = max(mx, (S - (a_max - a_min)));
}
}
cout << mx;
}
# | 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... |