Balanced tree simulation dp?
Let $dp[i] $denote the minimum value of the last bit of the legal subsequence with a length of $I $in the current state.
It is easy to find $DP [i] < DP [i + 1] $.
Then you can have $dp $.
(the current operable range is $[l,r] $)
1. $DP [I-1] < L $, with $dp[i]=min(dp[i],l) $.
At this time, $DP [I-1] < L \ Le DP [i] $.
2. $l \ Le DP [I-1] < R $,...