Advertisement
Guest User

Untitled

a guest
Sep 30th, 2018
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 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 days = Integer.parseInt(scanner.nextLine());
  7. int doctors = 7;
  8. double treated = 0;
  9. double untreated = 0;
  10.  
  11. for (int i = 1; i <= days; i++)
  12. {
  13. int patients = Integer.parseInt(scanner.nextLine());
  14.  
  15. if (i % 3 == 0 && untreated > treated)
  16. {
  17.  
  18. doctors += 1;
  19. }
  20.  
  21. if (patients < doctors)
  22. {
  23. treated += patients;
  24. }
  25. else
  26. {
  27. treated += doctors;
  28. untreated += patients - doctors;
  29. }
  30. }
  31. System.out.printf("Treated patients: %.0f.", treated);
  32. System.out.printf("%n Untreated patients: %.0f.", untreated);
  33.  
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement