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; 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());
ll ans[n]; ans[0] = v[0].second;
for (int i = 1; i < n; i++) {
ll x = ans[i-1] + v[i-1].first - v[i].first + v[i].second;
ans[i] = max(ans[i-1], x);
}
cout << ans[n-1];
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... |