486 auto *above =
new bool[n];
487 auto heights = set<unsigned int>();
488 auto m = map<unsigned int, vector<unsigned int>>();
489 for(
int i = 0; i < n; i++) {
492 heights.insert(height);
494 if(!m.contains(height)) {
495 m[height] = vector<unsigned int>();
497 m[height].push_back(i);
501 for(
auto height: heights) {
502 for(
const auto index: m[height]) {
503 above[index] =
false;
504 if(0 < index && index + 1 < n) {
505 if(above[index - 1] && above[index + 1]) {
507 }
else if(!above[index - 1] && !above[index + 1]) {
510 }
else if(index == 0 && !above[1] || index == n - 1 && !above[n - 2]) {