AmazonOA #132
Compute Remaining Tasks
估计中等可在线判题
Tasks are executed in order, and an unfinished task continues across shifts. The rules are completed according to the source's first two examples: when a shift finishes all tasks, output 0 and discard that shift's excess time, and the next shift starts again from the first task of the whole batch; there is no restart within the same shift.
输入格式
The first line contains n m (1..200000), followed by two lines with n task durations and m shift durations respectively, all in 1..10⁹.
输出格式
Output the m remaining task counts in shift order.
样例 1
输入:
3 3
1 4 4
9 1 4
输出:
0 2 1
样例 2
输入:
5 5
1 2 4 1 2
3 10 1 1 1
输出:
3 0 4 4 3
样例 3
输入:
5 5
2 4 5 1 1
1 5 1 5 2
输出:
5 3 3 1 0
样例说明
Example 1: the first shift finishes exactly, so output 0; after the restart, finishing the first task leaves 2, then finishing the second leaves 1. Example 2: the first shift finishes the first two tasks, leaving 3; the second shift finishes the rest and discards the excess; for the new batch the next three shifts leave 4, 4 and 3. Example 3: the cumulative times used are 1, 6, 7, 12, 14, leaving 5, 3, 3, 1, 0 respectively.