import java.util.Scanner; public class Cinema { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int capacity = Integer.parseInt(scanner.nextLine()); String input = scanner.nextLine(); int totalPeople = 0; double finalPrice = 0; double ticketPrice = 5.00; double discount = 5.00; while (!"Movie time!".equals(input)) { if (totalPeople <= capacity) { int numberOfPeople = Integer.parseInt(input); totalPeople += numberOfPeople; double currentSum = ticketPrice * numberOfPeople; if (numberOfPeople % 3 == 0) { currentSum -= discount; } finalPrice += currentSum; if (totalPeople > capacity) { finalPrice -= currentSum; break; } input = scanner.nextLine(); } } if ("Movie time!".equals(input)) { System.out.printf("There are %d seats left in the cinema.%n", capacity - totalPeople); } if (totalPeople > capacity) { System.out.println("The cinema is full."); } System.out.printf("Cinema income - %.0f lv.", finalPrice); } }