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 int long long
signed main() {
//your code goes here
int n;
cin >> n;
vector <pair <int, int>> arr = {};
for(int i = 0; i < n; i++) {
int s, v;
cin >> s >> v;
arr.push_back({s, v});
}
sort(arr.begin(), arr.end(), [&](auto left, auto right) {
return left.first < right.first;
});
int maxj = 0;
for(int i = 0; i < n; i++) {
int val = 0;
for(int j = i; j < n; j++) {
val += arr[j].second;
int val2 = arr[j].first-arr[i].first;
maxj = max(maxj, val-val2);
}
}
cout << maxj << endl;
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... |