슈콩

[SWEA] 주혁이의 복권 당첨 본문

Algorithms/SWEA

[SWEA] 주혁이의 복권 당첨

shukong 2025. 11. 25. 22:20

 

 

[문제]

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWh4FhG6Ei4DFAXp

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int T = Integer.parseInt(br.readLine());
		for(int tc=1;tc<=T;tc++) {
			st = new StringTokenizer(br.readLine());
			int n = Integer.parseInt(st.nextToken());
			int m = Integer.parseInt(st.nextToken());
			String[] lottos = new String[n];
			int[] price = new int[n]; 
			for(int i=0;i<n;i++) {
				st = new StringTokenizer(br.readLine());
				lottos[i] = st.nextToken();
				price[i] = Integer.parseInt(st.nextToken());
			}
			int result = 0;
			for(int i=0;i<m;i++) {
				String cmp = br.readLine();
				for(int j=0;j<n;j++) {
					String lotto = lottos[j];
					boolean check = true;
					for(int t=0;t<8;t++) {
						if(lotto.charAt(t)!='*' && cmp.charAt(t)!=lotto.charAt(t))
							check = false;
					}
					if(check) result += price[j];
				}
			}
			System.out.println("#"+tc+" "+result);
		}
	}
}

'Algorithms > SWEA' 카테고리의 다른 글

[SWEA] 방울 마술  (0) 2025.11.23
[SWEA] 육십갑자  (0) 2025.11.22
[SWEA] 문자열 교집합  (0) 2025.11.22
[SWEA] 두 수의 덧셈  (0) 2025.11.21
[SWEA] 다솔이의 월급 상자  (0) 2025.11.21