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>P(n + 1);
for(int i = 1;i <= n;++i){
P[i] = P[i - 1] + arts[i].second + arts[i - 1].first - arts[i].first;
// cout << "P[" << i << "]=" << P[i] << '\n';
}
long long mx = 0;
for(int i = 1;i <= n;++i){
for(int j = i;j <= n;++j){
long long num = (P[j] - P[i - 1]) - arts[i - 1].first + arts[i].first;
mx = max(mx, num);
}
}
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... |