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(false); cin.tie(NULL); cout.tie(NULL);
long long n;
cin >> n;
vector<pair<long long, long long> > works;
for (long long i=0; i<n; i++) {
long long siz, val;
cin >> siz >> val;
works.push_back(make_pair(siz, val));
}
sort(works.begin(), works.end());
long long best = LLONG_MIN;
for (long long i=0; i<n; i++) {
long long mn = works[i].first;
long long mx = mn;
long long value = 0;
for (long long j=i; j<n; j++) {
mx = max(mx, works[j].first);
value += works[j].second;
best = max(best, value - mx + mn);
}
}
cout << best << endl;
}
# | 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... |