ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1965. Саженцы груши

🎧 Vadim Barinov \Frez_Fstilus/'``' :) Hint for inc and dec case // Задача 1965. Саженцы груши 12 авг 2026 16:03
Let's use pref_m[i][x], pref_le[i][x], suff_m[i][x], suff_le[i][x] where:
pref_m[i][x] - on [0;i) elements > x are in decreasing order;
pref_le[i][x] - on [0;i) elements <= x are in increasing order;
suff_m[i][x] - on [i;n) elements > x are in increasing order;
suff_le[i][x] - on [i;n) elements <= x are in decreasing order.

There is inc-dec-solution if and only if there exists some pos and val such that pref_m[pos][val], pref_le[pos][val], suff_m[pos][val] and suff_le[pos][val] are all true.

In order not to get ML you need to remove either positions or values from these arrays. It's your call to chose