#K53347. Worker Schedule Adjustment

    ID: 29511 Type: Default 1000ms 256MiB

Worker Schedule Adjustment

Worker Schedule Adjustment

In this problem, you are given several test cases. For each test case, you are given two integers NN and KK, where NN is the number of schedule entries and KK is the maximum number of consecutive working days allowed. This is followed by a list of NN integers, where each integer DD represents the total number of days a worker is scheduled to work. Your task is to adjust each schedule by splitting the number DD into segments such that no segment exceeds KK. Formally, if DD is given, you must express it as [ D = q \times K + r \quad \text{with} \quad 0 \le r \le K, ] where qq is the number of full segments of KK days each, and rr is the remainder (if any). Output the adjusted segments for each test case in the order they appear, separated by spaces.

Example:

If $N=3$, $K=2$, and the schedule is [5, 3, 2], then for the number 5, you produce segments [2, 2, 1]; for 3 it is [2, 1]; and for 2 it remains [2]. The final output is the concatenation: 2 2 1 2 1 2.

inputFormat

The input is given via standard input (stdin) and consists of multiple test cases. The first line contains an integer TT, the number of test cases. For each test case:

  • The first line contains two integers $N$ and $K$, where $N$ represents the number of schedule entries and $K$ is the maximum allowed days per segment.
  • The second line contains $N$ integers, each representing a worker's scheduled number of days.
All values are separated by spaces.

outputFormat

For each test case, output a single line on standard output (stdout) containing the adjusted schedule segments separated by a space. Each segment is an integer no larger than KK.## sample

1
1 3
10
3 3 3 1