[Solution] Restoring the Duration of Tasks Codeforces Solution
Recently, Polycarp completed successive tasks.
For each completed task, the time is known when it was given, no two tasks were given at the same time. Also given is the time when the task was completed. For each task, there is an unknown value () — duration of task execution.
It is known that the tasks were completed in the order in
Solution Click Below:- CLICK HERE
which they came. Polycarp performed the tasks as follows:
- As soon as the very first task came, Polycarp immediately began to carry it out.
- If a new task arrived before Polycarp finished the previous one, he put the new task at the end of the queue.
- When Polycarp finished executing the next task and the queue was not empty, he immediately took a new task from the head of the queue (if the queue is empty — he just waited for the next task).
Find (duration) of each task.
The first line contains a single integer () — the number of test cases.
The descriptions of the input data sets follow.
The first line of each test case contains one integer ().
The second line of each test case contains exactly integers ().
The third line of each test case contains exactly integers ().
It is guaranteed that the sum of over all test cases does not exceed .
For each of test cases print positive integers — the duration of each task.
No comments:
Post a Comment