Round Robin Scheduler
Time limit2sMemory limit512 MB
Given each job's required seconds, compute its finishing time under a round robin scheduler that grants one second per turn in index order.
- Level
Medium6 of 10
- Topics
- Sorting, Prefix sum, Segment tree
- Solved
- No attempts yet
Problem
A single CPU runs several jobs at once, and the scheduler tells the CPU which job to run and when.
The scheduler in this problem is a round robin scheduler. There are jobs, numbered 0 through . Starting from job 0, the scheduler runs the jobs in order of their numbers and gives each job exactly 1 second per turn. After the last job it goes back to job 0 and repeats the same order. A job that has already finished is skipped and never runs again.
The scheduler starts at time 0, and one turn takes exactly 1 second.
Given the time each job needs, write a program that finds when each job finishes.
Input
The first line contains the number of jobs ().
The second line contains the time each job needs, from job 0 through job , separated by spaces. Each of these times is an integer between and .
Output
Print lines. Give the completion time of job 0 first and the completion time of job last.