Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tasks = [int(n) for n in input().split(', ')]
- indx = int(input())
- total_time = 0
- needed_task = tasks[indx]
- tasks_dict = {idx: value for idx, value in enumerate(tasks)}
- sorted_tasks = sorted(tasks_dict.items(), key=lambda kvp: (kvp[1], kvp[0]))
- for index, value in sorted_tasks:
- if (value < needed_task) or (value == needed_task and index <= indx):
- total_time += value
- else:
- break
- print(total_time)
Advertisement
Add Comment
Please, Sign In to add comment