← All problemsSign in

Add with Mod

CodeChefRating 2523Open on judge ↗

For a given pair of arrays $A$ and $B$, both of size $N$, we define: - $f(A, B)$ is defined as the minimum cost of a sequence of operations that transforms the array $A$ into the array $B$ using the following operations: - Rearrange the array $A$ arbitrarily for $0$ cost. - Choose some index $i$ ($1 \le i \le N$), modify $A_i$ to $(A_i + 1) \bmod N$ for a cost of $1$. For example, for $N

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