Advertisement
tchenkov

Exam_28.August.2016_P04_Болница

Mar 15th, 2017
117
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.  
  3. /**
  4.  * Created by todor on 16.02.2017 г..
  5.  */
  6. public class Dummy {
  7.     public static void main(String[] args) {
  8.         int doctors = 7;
  9.         Scanner scan = new Scanner(System.in);
  10.         int workDays = Integer.parseInt(scan.nextLine());
  11.        
  12.         int treatedPatients = 0;
  13.         int untreatedPatients = 0;
  14.         for (int i = 1; i <= workDays; i++) {
  15.             if (i % 3 == 0 && treatedPatients < untreatedPatients){
  16.                 doctors++;
  17.             }
  18.             int todayPatientsCount = Integer.parseInt(scan.nextLine());
  19.             boolean areDoctorsEnough = todayPatientsCount <= doctors;
  20.             untreatedPatients += areDoctorsEnough ? 0 : todayPatientsCount - doctors;
  21.             treatedPatients += areDoctorsEnough ? todayPatientsCount : doctors;
  22.         }
  23.         System.out.printf("Treated patients: %d.%n", treatedPatients);
  24.         System.out.printf("Untreated patients: %d.", untreatedPatients);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement