← All problemsSign in

Ratio By 2

CodeChefRating 1035Open on judge ↗

You have $2$ positive integers $X$ and $Y$. In one operation, you can change the value of **one** of the integers by $1$ or $-1$. Find the minimum number of operations needed to ensure that either $X \ge (2 \cdot Y)$ or $Y \ge (2 \cdot X)$, i.e. either $X$ is at least twice as large as $Y$, or $Y$ is at least twice as large as $X$. ### Input - The first line of input will contain a single inte

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