Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int voucherAmount = Integer.parseInt(scanner.nextLine()),
- ticketPurchased = 0, otherPurchased = 0;
- String command;
- while (!(command = scanner.nextLine()).equals("End")) {
- voucherAmount -= (int) command.charAt(0) + (command.length() > 8 ? (int) command.charAt(1) : 0);
- if (voucherAmount < 0) {
- break;
- }
- int i = command.length() > 8 ? ticketPurchased++ : otherPurchased++;
- }
- System.out.println(ticketPurchased + "\n" + otherPurchased);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement