← All problemsSign in

Subsequence

CodeChefRating 2774Open on judge ↗

Given a sequence $A$ of length $N$ and an integer $M$, such that the elements of $A$ are **pairwise distinct**. For each $k$ $(1\le k\le M)$, find the number of [subsequences](https://en.wikipedia.org/wiki/Subsequence) $A_{i_1},A_{i_2},\dots,A_{i_p}$ of $A$ satisfying the following conditions: - Condition $1$: $\sum_{j=1}^{p}A_{i_j}=k$. - Condition $2$: Let $f(l,r)=\max_{i=l}^{r}A_i$. Then, for

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