Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Hospital {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- Integer period = Integer.parseInt(scan.nextLine());
- Integer hostedPatients = 0;
- Integer nonhostedPatients = 0;
- Integer doctors = 7;
- for (int i = 1; i <= period; i++) {
- if (i % 3 == 0 && hostedPatients < nonhostedPatients){
- doctors++;
- }
- Integer dailyPatients = Integer.parseInt(scan.nextLine());
- int temp = Math.min(dailyPatients, doctors);
- hostedPatients += temp;
- nonhostedPatients += (dailyPatients - temp);
- }
- System.out.println("Treated patients: " + hostedPatients + ".");
- System.out.println("Untreated patients: " + nonhostedPatients + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement