Company: Emerson
Difficulty: medium
James Sequence Let X be a sequence of integers, and p a positive integer. We define the score of X to be the sum of the elements of X modulo p. James is given a sequence A that consists of N integers and also given integers k and p. James\' goal is to split A into k parts such that: Each part contains at least 1 element of A, and Each part consists of contiguous elements of A, No two parts overlap, The total sum S of the scores of those parts is maximized. Output the sum S. Input Format The first line of input contains an integer k, representing the number of parts A should be split into. The second line of input contains an integer p, representing the modulo for computing scores. The third line of input contains an integer N, representing the number of elements in A. The fourth line of input contains N space-separated integers, representing the sequence A. Output Format Print a single integer representing the maximum possible sum S of the scores of all parts. Constraints 2 ≤ p ≤ 100 k