Advertisement
CR7CR7

hospital

Apr 27th, 2023
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2. class HelloWorld {
  3.     public static void main(String[] args) {
  4.         Scanner sc =new Scanner(System.in);
  5.         int periodDays = Integer.parseInt(sc.nextLine());
  6.  
  7.         int patientsTreated = 0;
  8.         int patientsUntreated = 0;
  9.         int doctors = 7;
  10.  
  11.         for (int i = 1; i <= periodDays ; i++) {
  12.             int patients = Integer.parseInt(sc.nextLine());
  13.  
  14.             if (i % 3 == 0) {
  15.                 if (patientsTreated < patientsUntreated) {
  16.                     doctors++;
  17.                 }
  18.                
  19.             }
  20.             if (patients <= 7) {
  21.                 patientsTreated += patients;
  22.             } else {
  23.                 patientsTreated += doctors;
  24.                 patientsUntreated += patients - doctors;
  25.             }
  26.  
  27.  
  28.         }
  29.        
  30.        
  31.         System.out.printf("Treated patients: %d.%n",patientsTreated);
  32.         System.out.printf("Untreated patients: %d.%n",patientsUntreated);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement