Advertisement
psi_mmobile

Untitled

May 14th, 2022
766
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int days = scanner.nextInt();
  5.         int dailyUntreatedPatients = 0;
  6.         int dailyTreatedPatients = 0;
  7.         int dailyPatients = 0;
  8.         int numberOfDoctors = 7;
  9.        
  10.         int totalUntreatedPatients = 0;
  11.         int totalTreatedPatients = 0;
  12.        
  13.         for (int i = 1; i <= days; i++) {
  14.             dailyPatients = scanner.nextInt();
  15.             if (i % 3 == 0 && (totalUntreatedPatients > totalTreatedPatients)) {
  16.                 numberOfDoctors++;
  17.             }
  18.             if (dailyPatients < numberOfDoctors) {
  19.                 dailyTreatedPatients = dailyPatients;
  20.             } else {
  21.                 dailyTreatedPatients = numberOfDoctors;
  22.             }
  23.             dailyUntreatedPatients = dailyPatients - dailyTreatedPatients;
  24.            
  25.             totalUntreatedPatients += dailyUntreatedPatients;
  26.             totalTreatedPatients += dailyTreatedPatients;
  27.         }
  28.         System.out.printf("Treated patients: %d.\n",totalTreatedPatients);
  29.         System.out.printf("Untreated patients: %d.",totalUntreatedPatients);
  30.     }
  31. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement