이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 = 0;
for (int indPlat = 0; indPlat < nbPlats; ++indPlat) {
llg scoreBas = -(curSom - plats[indPlat].first);
curSom += plats[indPlat].second;
llg scoreHaut = curSom - plats[indPlat].first;
if (indPlat == 0) meilleurBas = scoreBas;
meilleurBas = max(meilleurBas, scoreBas);
ans = max(scoreHaut+meilleurBas, ans);
}
cout << ans << "\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... |