Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let countDays = Number(input[0]);
- let doctors = 7;
- let patientsUnattended = 0;
- let patientsAttended = 0;
- for (let i = 1; i <= countDays; i++) {
- let current = Number(input[i]);
- if (i % 3 === 0) {
- if (patientsAttended < patientsUnattended) {
- doctors += 1;
- }
- }
- if (doctors >= current) {
- patientsAttended += current;
- } else if (doctors < current) {
- patientsUnattended += current - doctors;
- patientsAttended += doctors;
- }
- }
- console.log(`Treated patients: ${patientsAttended}.`);
- console.log(`Untreated patients: ${patientsUnattended}.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement