← All problemsSign in

Minimal Inversions

CodeChefRating 1918Open on judge ↗

Initially, Chef had an array $A$ of length $N$. Chef performs the following operation on $A$ **at most** once: - Select $L$ and $R$ such that $1 \le L \le R \le N$ and set $A_i := A_i + 1$ for all $L \le i \le R$. Determine the **maximum** number of *inversions* Chef can decrease from the array $A$ by applying the operation **at most** once. More formally, let the final array obtained after app

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