← All problemsSign in

Best Sums

Given 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. In this problem, you will be given such a sequence and two integers P and K. Your task is to find the smallest partial sum modulo P that is at least K. For example, consider the following sequence of integers: 12 13 15 11 16 26 11 Here N = 7. Suppose K = 2 and P = 17. Th

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