Prefix Suffix LIS Counting
CodeChefOpen on judge ↗
Let's denote the length of the Longest Increasing Subsequence of the array $B$ by $\mathbf{LIS}(B)$. For a permutation $A$ of integers from $1$ to $N$ we can define two arrays of integers $P$ and $S$, both of length $N$: $P_i = \mathbf{LIS}(A[1:i]) = \mathbf{LIS}([A_1, A_2, \ldots, A_i])$, $S_i = \mathbf{LIS}(A[i:N]) = \mathbf{LIS}([A_i, A_{i+1}, \ldots, A_N])$. Let's call a pair of arrays $(P,
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start