Advertisement
Sasho_Cvetkov17101

bolnicata

Jan 20th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class bolnica {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int period = scanner.nextInt();
  8.         int treatedPatients = 0;
  9.         int untreatedPatients = 0;
  10.         int countOfDoctor = 7;
  11.  
  12.         for (int day = 1; day <= period; day++){
  13.             int currentPatients = scanner.nextInt();
  14.  
  15.             if ((day % 3 == 0) && (untreatedPatients > treatedPatients)){
  16.                 countOfDoctor++;
  17.             }
  18.  
  19.             if (currentPatients > countOfDoctor) {
  20.                 treatedPatients += countOfDoctor;
  21.                 untreatedPatients += currentPatients - countOfDoctor;
  22.             }else{
  23.                 treatedPatients += currentPatients;
  24.             }
  25.         }
  26.         System.out.printf("izlekuvani %d ", treatedPatients);
  27.         System.out.printf("che umrat %d", untreatedPatients);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement