#K56647. Partition Array into Equal Subarrays

    ID: 30245 Type: Default 1000ms 256MiB

Partition Array into Equal Subarrays

Partition Array into Equal Subarrays

You are given an integer (n), an integer (k), and an array of (n) integers. Your task is to partition the array into contiguous subarrays, each of exactly (k) elements. If (n) is not divisible by (k) (i.e. (n \bmod k \neq 0)), then partitioning is impossible and you should output "NO". Otherwise, output "YES" followed by the subarrays, each on its own line with the elements separated by spaces.

For example, if (n = 6), (k = 3) and the array is [3, 2, 5, 4, 1, 6], the answer is:

YES 3 2 5 4 1 6

inputFormat

The first line contains two integers (n) and (k) separated by a space. The second line contains (n) space-separated integers representing the array.

outputFormat

If partitioning is possible, print "YES" in the first line and then print the subarrays (each subarray in a new line with its (k) elements separated by spaces). If partitioning is not possible, print only "NO".## sample

6 3
3 2 5 4 1 6
YES

3 2 5 4 1 6

</p>