H - P to Q
CodeChefOpen on judge ↗
You are given $2$ permutations $P$ and $Q$ of the integers $1$ to $N$. Your score $S$ is initialized as $\text{inversions}(P)^{\dagger}$. You can do the following operation at most $10 \cdot N$ times: - Select any integer $x$ satisfying $1 \le x \le N$. Delete $x$ from $P$, and then insert $x$ back into $P$ in any desired location. Replace $S$ with $\max(S, \text{inversions}(P))$. Your goa
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