#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long llg;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int nbPlats;
cin >> nbPlats;
vector<pair<llg, llg>> plats(nbPlats);
for (int indPlat = 0; indPlat < nbPlats; ++indPlat) {
// Taille puis valeur
cin >> plats[indPlat].first >> plats[indPlat].second;
}
// Tri par taille
sort(plats.begin(), plats.end());
llg curSom = 0;
llg ans = 0;
llg meilleurBas = - ((llg)(1e9) * (llg)(1e9));
for (int indPlat = 0; indPlat < nbPlats; ++indPlat) {
llg scoreBas = -(curSom - plats[indPlat].first);
curSom += plats[indPlat].second;
llg scoreHaut = curSom - plats[indPlat].first;
ans = max(scoreHaut+meilleurBas, ans);
meilleurBas = max(meilleurBas, scoreBas);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |