← All problemsSign in

Counting Is Fun

CodeChefRating 2892Open on judge ↗

Consider two **binary** arrays $A$ and $B$, each of size $N$ and a permutation$^\dagger$ $P$ of length $N$. You will make two new arrays $C$ and $D$, each of size $N$, such that: - $C_i=A_{P_i}$ ($1 \leq i \leq N$) - $D_i=B_{P_i}$ ($1 \leq i \leq N$) Let us define: - The score of the permutation $P$ as $\min(\text{LNDS}(C),\text{LNDS}(D))$, where $\text{LNDS}(X)$ gives the length of **longes

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