← All problemsSign in

Stack-Queue Sort (Challenge)

CodeChefRating 3660Open on judge ↗

There are $B$ blocks (numbered $1$ through $B$) distributed in $N$ containers (numbered $1$ through $N$). For each valid $i$, the weight of the $i$-th block is $W_i$ kilograms. For each container $i$, you should decide if it will be used like a *stack* or a *queue*. At any time, a container may contain any sequence of blocks (possibly the empty sequence); let's denote the number of the $j$-th b

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