Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import heapq
  2.  
  3.  
  4. def main():
  5. n, x, k = map(int, input().split(" "))
  6. times = list(map(int, input().split(" ")))
  7.  
  8. heapq.heapify(times)
  9.  
  10. answers = []
  11.  
  12. while k:
  13. v = heapq.heappop(times)
  14. heapq.heappush(times, v + x)
  15.  
  16. if len(answers) == 0 or answers[len(answers)-1] != v:
  17. answers.append(v)
  18. k -= 1
  19.  
  20. print(answers[k-1])
  21.  
  22.  
  23. if __name__ == "__main__":
  24. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement