← All problemsSign in

Sign Moves

CodeChefRating 1126Open on judge ↗

Initially, Chef is at coordinate $0$ on X-axis. For each $i = 1, 2, \dots, N$ in order, Chef does the following: - If Chef is at a **non-negative** coordinate, he moves $i$ steps backward (i.e, his position's coordinate decreases by $i$), otherwise he moves $i$ steps forward (i.e, his position's coordinate increases by $i$). You are given the integer $N$. Find the final position of Chef on the X

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