#P1956. Minimum Subarray Sum Modulo
Minimum Subarray Sum Modulo
Minimum Subarray Sum Modulo
You are given an array of integers \(a_1, a_2, \ldots, a_n\) along with two integers \(k\) and \(p\). Define the subarray sum \(S_{i,j} = \sum_{t=i}^{j} a_t\) for any \(1 \le i \le j \le n\). Your task is to compute:
[ Answer = \min{ S_{i,j}\bmod p \mid S_{i,j}\bmod p \ge k }]
It is guaranteed that there exists at least one subarray \( [i,j] \) such that \(S_{i,j}\bmod p \ge k\).
Note: All formulas are written in LaTeX format.
inputFormat
The first line contains three integers: \(n\) (the number of elements in the array), \(k\), and \(p\) (modulus).
The second line contains \(n\) space-separated integers representing the array \(a_1, a_2, \ldots, a_n\).
outputFormat
Output a single integer: the value of \(Answer\) as defined above.
sample
5 3 7
3 1 4 1 5
3