← All problemsSign in

Eat Rock!

CodeChefRating 2786Open on judge ↗

Rockeater Rocky is on a mission to eat rocks! There are $N$ rocks on the $X$-axis. The $i^{th}$ of these rocks is at position $X_i$ and has weight $W_i$. All the $W_i$ are **distinct**. Consider a subset $S$ consisting of $k$ rocks. Rocky will eat the rocks in $S$ as follows: - Let $i_1, i_2, \ldots, i_k$ be the list of indices of rocks in $S$, sorted in **ascending** order of weight. - Th

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