SP25015 KNMD - Subsequences with modulo
Description
You are given sequence _A $ _{1} $ , A $ _{2} $ , ... A $ _{n} $_ and integer _k_. For each integer _i_ _(0 find such **nonempty** subsequence of _A_ so that sum of numbers in this subsequence is maximal possible and remainder of integer division of this sum by _k_ is equal to _i_._
Input Format
In first line numbers _n_ and _k (1 ._
In second line: _n_ numbers representing sequence _A (1 ._
Output Format
Print _k_ numbers in one line. _i_'th number represent sum of numbers in subsequence for number _i - 1_. If there is no such subsequence print -1.