IntermediateRating 1400
Taking Turns on the CPU
Jobs need t₁, t₂, … units of time. A scheduler gives each unfinished job q units in turn (less if it needs less), cycling through jobs 1, 2, …, n. Print the time at which each job finishes.
Input
n and q, then n times.
Output
n integers.
Sample 1
Input
3 2 5 3 1
Output
9 8 5
Sample 2
Input
1 10 4
Output
4
Output appears here