← All problemsSign in

Shift And Sort

CodeChefRating 1689Open on judge ↗

You are given an array $A$ of length $N$. You can modify it via the following operation: - Choose an integer $k \ge 0$. - Choose $k$ indices $i_1 < i_2 < \ldots < i_k$ such that: - $1 \le i_1$, - $i_j - i_{j-1} \gt 1$ for each $1 \lt j \le k$; and - $i_k \lt N$ - Choose $k$ **positive** integers $x_1, x_2, \ldots, x_k$. - Finally, for each $1 \le j \le k$, subtract $x_j$ from $A_{i_j}

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