Guest User

Untitled

a guest
Jun 13th, 2018
205
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(params) {
  2.     let period = Number(params[0]);
  3.     let treated = 0;
  4.     let untreated = 0;
  5.     let doctors = 7;
  6.     for (let i = 1; i <= period; i++) {
  7.         let patients = Number(params[i]);
  8.         if (i % 3 == 0 && untreated > treated) {
  9.             doctors++;
  10.         }
  11.  
  12.         if (patients <= doctors) {
  13.             treated += patients;
  14.         }
  15.         else {
  16.             treated += doctors;
  17.             untreated += patients - doctors;
  18.         }
  19.     }
  20.     console.log(`Treated patients: ${treated}.`);
  21.     console.log(`Untreated patients: ${untreated}.`);
  22. }
RAW Paste Data