Advertisement
yatochk

2

Jan 24th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. firstLine = input().split()
  2. secondLine = input().split()
  3.  
  4. count = int(firstLine[0])
  5. allTime = int(firstLine[1])
  6. relaxTime = int(firstLine[2])
  7.  
  8. times = [int(item) for item in secondLine]
  9.  
  10. hardTime = -1
  11.  
  12. for i in range(count):
  13.     allTime -= times[i]
  14.  
  15. if allTime >= 0:
  16.     times.pop()
  17.     relaxCount = allTime // relaxTime
  18.     times.sort()
  19.     if relaxCount - 1 >= count - 1:
  20.         hardTime = 1
  21.     else:
  22.         if (len(times) == 0):
  23.             hardTime = 1
  24.         else:
  25.             hardTime = times[-1 - relaxCount] + 1
  26. elif allTime < 0:
  27.     hardTime = -1
  28.  
  29. print(hardTime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement