Non-decreasing AND and OR
You are given three positive integers $N$, $M$ and $K$. An array of integers $A_1, A_2, \dots, A_N$ is *good* if the following statements hold: - $0 \leq A_i \leq M$ for each ($1 \leq i \leq N$) - $(A_i \; \& \; K) \leq (A_{i+1} \; \& \; K)$ for each ($1 \leq i \leq N-1$) - $(A_i \; | \; K) \leq (A_{i+1} \; | \; K)$ for each ($1 \leq i \leq N-1$) Here, $\&$ denotes the [bitwise AND operation](h
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.
Sign in to chat with the tutor and save your progress.
Sign in to start