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;
using ll = long long;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,l,p;
cin >> n;
vector<pair<ll,ll>>ciag;
vector<ll>ciag2(1);
for(int i=0;i<n;++i){
cin >> l >> p;
ciag.push_back({l,p});
}
sort(ciag.begin(),ciag.end());
for(int i=0;i<n;++i){
ciag2.push_back(ciag2[i]+ciag[i].second);
}
/*for(int i=0;i<ciag2.size();++i){
cout << ciag2[i] << ' ';
}
cout << endl;
*/
ll wynik=0,wynik2=0;
vector<ll>maksy;
for(int i=0;i<n;++i){
wynik=max(ciag2[i]*-1+ciag[i].first,wynik);
maksy.push_back(wynik);
}
/*for(int i=0;i<n;++i){
cout << maksy[i] << ' ';
}
cout << endl;
*/
for(int i=0;i<n;++i){
wynik2=max(ciag2[i+1]-ciag[i].first+maksy[i],wynik2);
}
cout << wynik2;
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... |