← All problemsSign in

Increasing Addition

CodeChefRating 2155Open on judge ↗

You have an array $A$ of length $N$. In one operation, you can do the following: - Select any subarray $A_{L \ldots R}$ $(1 \le L \le R \le N)$ and then add $i$ to the $i$-th element of this subarray. Formally, we set $A_j := A_j + (j - L + 1)$ for all $L \le j \le R$. For example: if $A = [2, 1, 5, 2]$ and we apply operation on $A_{2 \ldots 4}$ then $A$ becomes $[2, 1 + 1, 5 + 2, 2 + 3] = [2, 2

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