D - Minimum Cost
CodeChefOpen on judge ↗
An array of integers $P1,P2,…,Pn$ is called a permutation if it contains each number from $1$ to $n$ exactly once. For example, the following arrays $ [1,2,3],[1],[4,3,2,1]$ are permutations. The following arrays $[2],[1,1],[2,4,1]$ are not permutations. You are standing at position $1$. From position $i$, you can travel to $ j(1<=j<=n)$ with cost $|i-j|*X$ . From position $i$, you can also trave
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