#K53347. Worker Schedule Adjustment
Worker Schedule Adjustment
Worker Schedule Adjustment
In this problem, you are given several test cases. For each test case, you are given two integers and , where is the number of schedule entries and is the maximum number of consecutive working days allowed. This is followed by a list of integers, where each integer represents the total number of days a worker is scheduled to work. Your task is to adjust each schedule by splitting the number into segments such that no segment exceeds . Formally, if is given, you must express it as [ D = q \times K + r \quad \text{with} \quad 0 \le r \le K, ] where is the number of full segments of days each, and 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 , 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.
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 .## sample
1
1 3
10
3 3 3 1