← All problemsSign in

Not a Real World Problem

CodeChefRating 2871Open on judge ↗

Consider a grid with $H$ rows (numbered $1$ through $H$) and $W$ columns (numbered $1$ through $W$). Let's denote the value in a cell in row $i$ and column $j$ by $h_{i,j}$. $N$ particles (numbered $1$ through $N$) are distributed in the cells in such a way that there is at most one particle in each cell. For each valid $i$, the $i$-th particle has a value $p_i$ and it is placed in the cell in row

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