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>
#define fast_input_output() ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
typedef long long ll;
using namespace std;
int main() {
fast_input_output();
ll n, ans = LLONG_MIN; cin >> n;
vector<pair<ll, ll>> v(n);
for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
ll s = v[i].second; ans = max(ans, s);
for (int j = i + 1; j < n; j++) {
s += v[j].second;
ans = max(ans, s - (v[j].first - v[i].first));
if (s - (v[j].first - v[i].first) == 10) cout << i << ' ' << j << '\n';
}
}
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... |