← All problemsSign in

SUM IT UP

For a sequence of positive integers a1, a2, …, aN, and 1 ≤ i ≤ j ≤ N, the partial sum from i to j is ai + ai+1 + … + aj. You would be given such sequences and two integers P and K. Objective is to find the smallest partial sum modulo P that is at least K. For example, consider the sequence: 12 13 15 11 16 26 11 Here N = 7. Suppose K = 2 and P = 17. Then, the answer i

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