← All problemsSign in

LIS and LDS

CodeChefRating 1822Open on judge ↗

You are given a frequency array $F$ of size $N$. An array $A$ of size $(F_1 + F_2 + \ldots + F_N)$ is called *good* if it contains the integer $X$ exactly $F_X$ times, for each $1 \le X \le N$. The score of an array $A$ is defined as $\min(LIS(A), LDS(A))$, where $LIS(A)$ denotes the longest (strictly) increasing subsequence of $A$, and $LDS(A)$ denotes the longest (strictly) decreasing subsequen

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start