← All problemsSign in

Chef and the Combination Lock

CodeChefRating 2745Open on judge ↗

Chef has a combination lock with $N$ wheels (numbered $1$ through $N$). For each valid $i$, on the $i$-th wheel, the integers from $0$ to $A_i$ (inclusive) are written in ascending order ($0$ and $A_i$ are also adjacent). Initially, one value on each wheel is selected uniformly randomly and independently. The lock operates in a very peculiar way: it opens when there is at least one wheel where

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