Costly Swapping
$X$ and $Y$ are binary sequences of length $N$, i.e. $0 \le X_i, Y_i \le 1$. There are $4$ positive integer parameters $A$, $B$, $C$, and $D$. You can do the following set of operations any number of times: - Choose $2$ indices $i$ and $j$ such that $1 \le i < j \le N$. - Perform **exactly** one of the following actions: - Swap $X_i$ and $X_j$, paying a cost of $A$ if $X_i = 1$ (after the sw
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.
Sign in to chat with the tutor and save your progress.
Sign in to start