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>
typedef long long ll;
using namespace std;
int main(){
int n;
cin >> n;
pair<ll, ll> obr[n];
for(int i = 0; i < n; i++){
cin >> obr[i].first;
cin >> obr[i].second;
}
ll pre[n];
sort(obr, obr + n);
pre[n-1] = obr[n-1].second;
for(int i = n-2; i >= 0; i--){
pre[i] = obr[i].second + obr[i].first - obr[i+1].first;
}
ll suma = 0;
ll wynik = 0;
for(int i = n-1; i >= 0; i--){
suma += pre[i];
suma = max(suma, obr[i].second);
wynik = max(wynik, suma);
}
cout << wynik << "\n";
}
# | 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... |