didkoslawow

Untitled

Oct 4th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. function hospital(input) {
  2. let period = Number(input[0]);
  3. let patientsDaylyCounter = 0;
  4. let doctors = 7;
  5. let treatenPatients = 0;
  6. let totalTreated = 0;
  7. let untreatenPatients = 0;
  8.  
  9. for (let i = 1; i < period; i++) {
  10. patientsDaylyCounter = Number(input[i]);
  11. if (i % 3 === 0) {
  12. if (untreatenPatients > treatenPatients) {
  13. doctors++;
  14. }
  15. }
  16. if (patientsDaylyCounter > doctors) {
  17. untreatenPatients += patientsDaylyCounter - doctors;
  18. treatenPatients += patientsDaylyCounter - untreatenPatients;
  19. } else {
  20. treatenPatients += doctors;
  21. }
  22.  
  23.  
  24. }
  25. console.log(`Treated patients: ${treatenPatients}.`);
  26. console.log(`Untreated patients: ${untreatenPatients}.`);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment