← All problemsSign in

Longest Constrained Subsequence

CodeChefRating 2575Open on judge ↗

You are given two arrays of length N. Array A = $A$1, $A$2, ..., $A$N. Array L = $L$1, $L$2, ..., $L$N. For every k such that $1 \leq k \leq N$, you have to find the length of the longest possible subsequence in the first k elements of array A such that if $A$j immediately follows $A$i in the subsequence, then $|A$j$-A$i$| \leq L$j Please note that the input is __encrypted__. Read Input section f

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