Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- int days = scanner.nextInt();
- int dailyUntreatedPatients = 0;
- int dailyTreatedPatients = 0;
- int dailyPatients = 0;
- int numberOfDoctors = 7;
- int totalUntreatedPatients = 0;
- int totalTreatedPatients = 0;
- for (int i = 1; i <= days; i++) {
- dailyPatients = scanner.nextInt();
- if (i % 3 == 0 && (totalUntreatedPatients > totalTreatedPatients)) {
- numberOfDoctors++;
- }
- if (dailyPatients < numberOfDoctors) {
- dailyTreatedPatients = dailyPatients;
- } else {
- dailyTreatedPatients = numberOfDoctors;
- }
- dailyUntreatedPatients = dailyPatients - dailyTreatedPatients;
- totalUntreatedPatients += dailyUntreatedPatients;
- totalTreatedPatients += dailyTreatedPatients;
- }
- System.out.printf("Treated patients: %d.\n",totalTreatedPatients);
- System.out.printf("Untreated patients: %d.",totalUntreatedPatients);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement