← All problemsSign in

Chef and Array (Challenge)

CodeChefRating 3561Open on judge ↗

Chef has an integer $K$ and a randomly generated sequence $A_1, A_2, \dots, A_N$. He asks you to choose $N$ non-negative integers $D_1, D_2, \dots, D_N$ such that $D_i \le K$ for each valid $i$ and add $D_i$ to $A_i$ for each valid $i$. Also, Chef has $M$ primes $P_1, P_2, \dots, P_M$. It is guaranteed that for each valid $i$, $P_i$ is the smallest prime greater than $P_{i-1}$. After all addition

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