I don't remember which ones doesn't pass though
Okay, this one was tough, segtree with dp? At least it's pretty similar to LIS with dp...