← All problemsSign in

Triple Inversions

CodeChefRating 2169Open on judge ↗

For a [permutation](https://en.wikipedia.org/wiki/Permutation) $P$ of the integers $1$ to $N$, we define a new array $A_P$ of length $N-2$ as follows: - For $1 \leq i \leq N-2$, $(A_P)_i$ denotes the number of [inversions](https://en.wikipedia.org/wiki/Inversion_(discrete_mathematics)) in the subarray $P[i : i+2]$, i.e, the number of inversions in the array $[P_i, P_{i+1}, P_{i+2}]$. You are giv

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