Baekjoon - 17219

Tadap·2023년 10월 24일
0

Baekjoon

목록 보기
63/94
post-custom-banner

문제

Solved.ac Class3++

1차시도

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] counts = br.readLine().split(" ");
		int dataSize = Integer.parseInt(counts[0]);
		int askSize = Integer.parseInt(counts[1]);
		Map<String, String> values = new HashMap<>();

		for (int i = 0; i < dataSize; i++) {
			String[] data = br.readLine().split(" ");
			values.put(data[0], data[1]);
		}

		for (int i = 0; i < askSize; i++) {
			sb.append(values.get(br.readLine())).append("\n");
		}
		System.out.println(sb);
	}
}

성공

ToKotlin

fun main() {
    val sb = StringBuilder()
    val counts = readln().split(" ")

    val dataSize = counts[0].toInt()
    val askSize = counts[1].toInt()
    val values: HashMap<String, String> = HashMap()

    for (i in 0..<dataSize) {
        val data = readln().split(" ")
        values.put(data[0], data[1])
    }

    for (i in 0..<askSize) {
        sb.append(values.get(readln())).append("\n")
    }
    print(sb)
}

post-custom-banner

0개의 댓글