Dynamic programming with the interval $[l, r)$ as the domain of definition
There are several patterns in how to ask for it (sometimes in combination).
2: Section DP to be divided into
3: Number of times to remove columns that satisfy the condition from the column
https://www.hamayanhamayan.com/entry/2017/02/27/152226
https://www.hamayanhamayan.com/entry/2017/03/20/234711
This page is auto-translated from /nishio/区間DP using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.