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 scanner = new Scanner(System.in);
- int period = Integer.parseInt(scanner.nextLine());
- int treated = 0, untreated = 0, doctors = 7;
- for (int i = 1; i <= period; i++) {
- int patients = Integer.parseInt(scanner.nextLine());
- if (untreated > treated && i % 3 == 0) {
- doctors++;
- }
- if (patients > doctors) {
- treated += doctors;
- untreated += patients - doctors;
- } else {
- treated += patients;
- }
- }
- System.out.printf("Treated patients: %d.\n", treated);
- System.out.printf("Untreated patients: %d.\n", untreated);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement