Advertisement
16120

4.5

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