Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Per year calculation function
- def calculate(paitentsPerDay,R1,R2,TvRooms,N):
- amount = 0
- for paitent in paitentsPerDay:
- NTVRooms = N - TvRooms
- if paitent <= NTVRooms:
- amount = amount + (paitent * R2)
- elif paitent >= NTVRooms and paitent <= N:
- TVPaitent = paitent - NTVRooms
- amount = amount + (TVPaitent * R1) + (NTVRooms * R2)
- elif paitent > N:
- amount = amount + (NTVRooms * R2) + (TvRooms * R1)
- return amount
- # Days In Month
- days = {
- 1 : 31,
- 2 : 28,
- 3 : 31,
- 4 : 30,
- 5 : 31,
- 6 : 30,
- 7 : 31,
- 8 : 31,
- 9 : 30,
- 10 : 31,
- 11 : 30,
- 12 : 31,
- }
- # Input handler
- N = int(input())
- R1, R2 = list(map(int,input().split()))
- threshold = int(input())
- # Limiting Variables
- found = False
- rooms = 0
- # Calculate Paitents Per Day
- patientsPerDay = []
- for month in range(1,13):
- for day in range(1, days[month] + 1):
- perDay = ((6 - month)**2) + (abs(day - 15))
- patientsPerDay.append(perDay)
- # Calculate Min Number Of Rooms
- for Tvroom in range(1,N+1):
- if calculate(patientsPerDay,R1,R2,Tvroom,N) >= threshold:
- found = True
- rooms = Tvroom
- break
- else:
- continue
- print(rooms if found else N)
Add Comment
Please, Sign In to add comment