Advertisement
Spocoman

02. Hospital

Aug 28th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hospital {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int period = Integer.parseInt(scanner.nextLine());
  7.         int treated = 0, untreated = 0, doctors = 7;
  8.  
  9.         for (int i = 1; i <= period; i++) {
  10.             int patients = Integer.parseInt(scanner.nextLine());
  11.             if (untreated > treated && i % 3 == 0) {
  12.                 doctors++;
  13.             }
  14.             if (patients > doctors) {
  15.                 treated += doctors;
  16.                 untreated += patients - doctors;
  17.             } else {
  18.                 treated += patients;
  19.             }
  20.         }
  21.  
  22.         System.out.printf("Treated patients: %d.\n", treated);
  23.         System.out.printf("Untreated patients: %d.\n", untreated);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement