백준 27964 java : 자료구조

magicdrill·2025년 5월 14일
0

백준 문제풀이

목록 보기
604/654

백준 27964 java : 자료구조

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class bj27964 {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N, i;
        String topping;

        N = sc.nextInt();
        Set<String> toppings = new HashSet<>();
        for (i = 0; i < N; i++) {
            topping = sc.next();
            if(topping.endsWith("Cheese")) {
                toppings.add(topping);
            }
        }

        for(String cheese: toppings) {
            System.out.println(cheese);
        }

        if(toppings.size() >= 4) {
            System.out.println("yummy");
        }
        else{
            System.out.println("sad");
        }
    }
}

0개의 댓글