#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);
int n,l,p;
cin >> n;
vector<pair<int,int>>ciag;
vector<int>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);
}
int wynik=0,wynik2=0;
vector<int>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){
wynik2=max(ciag2[i]*-1+ciag[i].first+maksy[i],wynik2);
}
cout << wynik2;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |