Advertisement
Spocoman

02. Hospital

Dec 26th, 2021 (edited)
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. period = int(input())
  2. treated = 0
  3. untreated = 0
  4. doctors = 7
  5.  
  6. for i in range(1, period + 1):
  7.     patients = int(input())
  8.     if untreated > treated and i % 3 == 0:
  9.         doctors += 1
  10.     if patients > doctors:
  11.         treated += doctors
  12.         untreated += patients - doctors
  13.     else:
  14.         treated += patients
  15.  
  16. print(f'Treated patients: {treated}.\nUntreated patients: {untreated}.')
  17.  
  18. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  19.  
  20. period = int(input())
  21. treated = 0
  22. untreated = 0
  23. doctors = 7
  24.  
  25. for i in range(1, period + 1):
  26.     patients = int(input())
  27.     doctors += (1 if untreated > treated and i % 3 == 0 else 0)
  28.     treated += (doctors if patients > doctors else patients)
  29.     untreated += (patients - doctors if patients > doctors else 0)
  30.  
  31. print(f'Treated patients: {treated}.\nUntreated patients: {untreated}.')
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement