Mr_HO1A

Television Sets Codevita

Jun 21st, 2020
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. # Per year calculation function
  2. def calculate(paitentsPerDay,R1,R2,TvRooms,N):
  3.     amount = 0
  4.     for paitent in paitentsPerDay:
  5.         NTVRooms = N - TvRooms
  6.         if paitent <= NTVRooms:
  7.             amount = amount + (paitent * R2)
  8.         elif paitent >= NTVRooms and paitent <= N:
  9.             TVPaitent = paitent - NTVRooms
  10.             amount = amount + (TVPaitent * R1) + (NTVRooms * R2)
  11.         elif paitent > N:
  12.             amount = amount + (NTVRooms * R2) + (TvRooms * R1)
  13.  
  14.     return amount
  15.  
  16. # Days In Month
  17. days = {
  18.     1 : 31,
  19.     2 : 28,
  20.     3 : 31,
  21.     4 : 30,
  22.     5 : 31,
  23.     6 : 30,
  24.     7 : 31,
  25.     8 : 31,
  26.     9 : 30,
  27.     10 : 31,
  28.     11 : 30,
  29.     12 : 31,
  30. }
  31.  
  32. # Input handler
  33. N = int(input())
  34. R1, R2 = list(map(int,input().split()))
  35. threshold = int(input())
  36.  
  37.  
  38. # Limiting Variables
  39. found = False
  40. rooms = 0
  41.  
  42. # Calculate Paitents Per Day
  43. patientsPerDay = []
  44. for month in range(1,13):
  45.     for day in range(1, days[month] + 1):
  46.         perDay = ((6 - month)**2) + (abs(day - 15))
  47.         patientsPerDay.append(perDay)
  48.  
  49. # Calculate Min Number Of Rooms
  50. for Tvroom in range(1,N+1):
  51.     if calculate(patientsPerDay,R1,R2,Tvroom,N) >= threshold:
  52.         found = True
  53.         rooms = Tvroom
  54.         break
  55.     else:
  56.         continue
  57.  
  58. print(rooms if found else N)
Add Comment
Please, Sign In to add comment