[D3] 주혁이의 복권 당첨 - 6900
성능 요약
메모리: 60,936 KB, 시간: 245 ms, 코드길이: 1,216 Bytes
제출 일자
2023-11-13 09:54
출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
import java.util.Scanner;
import java.util.HashMap;
class Solution {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int tc = 1; tc <= T; tc++) {
int n = sc.nextInt();
int m = sc.nextInt();
String[] lottos = new String[n];
HashMap<String, Integer> map = new HashMap<>();
String[] checks = new String[m];
for(int i = 0; i < n; i++){
lottos[i] = sc.next();
map.put(lottos[i],sc.nextInt());
}
int result = 0;
for(int i = 0; i < m; i++){
String checkNum = sc.next();
for(int j = 0; j < n; j++){
if(check(checkNum,lottos[j])){
result += map.get(lottos[j]);
}
}
}
System.out.println("#" + tc + " " + result);
}
}
private static boolean check(String check, String lotto){
for(int i = 0; i < 8; i++){
if(check.charAt(i) != lotto.charAt(i) && lotto.charAt(i) != '*'){
return false;
}
}
return true;
}
}
'알고리즘 - SWEA > D3' 카테고리의 다른 글
[SW expert Academy] SWEA 8457번 알 덴테 스파게티 자바(Java) (0) | 2023.11.13 |
---|---|
[SW expert Academy] SWEA 3233번 정삼각형 분할 놀이 자바(Java) (0) | 2023.11.13 |
[SW expert Academy] SWEA 3376번 파도반 수열 자바(Java) (1) | 2023.11.13 |
[SW expert Academy] SWEA 10761번 신뢰 자바(Java) (0) | 2023.11.12 |
[SW expert Academy] SWEA 10032번 과자 분배 자바(Java) (0) | 2023.11.12 |