Advertisement
Guest User

Untitled

a guest
Feb 4th, 2022
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. jobs = [int(job) for job in input().split(', ')]
  2. index = int(input())
  3. cycles = 0
  4. current_index = -1
  5.  
  6. while current_index != index:
  7.     current_index = jobs.index(min(jobs))  # first occurrence of the min amount of clock cycles
  8.     current_job = min(jobs)   # take the amount of min clock cycles
  9.     jobs[current_index] = max(jobs) + 1         # set element on current index to max + 1 to not get processed again
  10.     cycles += current_job    # add the clock cycles
  11. print(cycles)
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement