YavorGrancharov

Hospital

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