← All problemsSign in

Random Permutation

CodeChefRating 3432Open on judge ↗

Chef has a random permutation $P_1, P_2, \ldots, P_N$ and an integer $K$. A subsequence (not necessarily contiguous) of this permutation is called *good* if it has at most $K$ pairs of neighbouring elements such that the left element is larger than the right element. Chef wants to know the maximum length of a good subsequence of his permutation. Can you help him? ### Input - The first line of t

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