https://www.acmicpc.net/problem/27160
백준 17160 (할리갈리)



HashMap<String, Integer> 사용하여HashMap에 저장된 값들 중 5인 값이 있는지 확인"YES", 아니면 "NO"를 출력 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
HashMap<String, Integer> fruit = new HashMap<>();
for (int i = 0; i < N; i++){
String[] cards = br.readLine().split(" ");
if (fruit.containsKey(cards[0])){
fruit.put(cards[0], fruit.get(cards[0]) + Integer.parseInt(cards[1]));
}
else {
fruit.put(cards[0], Integer.parseInt(cards[1]));
}
}
if (fruit.containsValue(5)){
System.out.println("YES");
}
else {
System.out.println("NO");
}
br.close();
}
}