← All problemsSign in

Chef and Line

CodeChefRating 2005Open on judge ↗

Chef has a sequence A with length N and a line given by the equation y(x) = k · x + b. Let us say that an element Aj is reachable from another element Ai if the point (Ai, Aj) is lying above or on the line y(x), i.e. if Aj ≥ k · Ai + b. Consider an arbitrary subsequence of A; let's denote it by B. Subsequence B is called good if its elements can be reordered in such a way that for each valid i, B

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