Group division - MarisaOJ: Marisa Online Judge

Group division

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ consisting of $n$ integers, find a way to divide the array into $k$ groups such that each group has the same sum. Each group must contain at least one element. ### Input - The first line contains two integers $n,k$. - The second line contains $n$ integers $A_i$. ### Output - Print $n$ integers, where the $i$-th integer represents the group of the $i$-th element. If there are multiple valid answers, print any of them. - If there is no solution, print `ze`. ### Constraints - $2 \le k < n \le 10$. - $1 \le A_i \le 100$. ### Example Input: ``` 5 3 1 4 6 9 10 ``` Output: ``` 1 3 3 1 2 ``` Explanation: - The first group consists of two elements $A_2 + A_3 = 4 + 6 = 10$. - The second group consists of one element $A_5 = 10$. - The third group consists of two elements $A_1+A_4=1+9=10$. The answer `1 2 2 1 3` or `3 1 1 3 2` are also acceptable answers.