문제 출처 : https://www.acmicpc.net/problem/28249
언어 : Kotlin
문제 설명 :
Ron is cooking chili using an assortment of peppers.
The spiciness of a pepper is measured in Scoville Heat Units (SHU). Ron's chili is currently not spicy at all, but each time Ron adds a pepper, the total spiciness of the chili increases by the SHU value of that pepper.
The SHU values of the peppers available to Ron are shown in the following table:
Pepper Name | Scolville Heat Units |
Poblano | 1500 |
Mirasol | 6000 |
Serrano | 15500 |
Cayenne | 40000 |
Thai | 75000 |
Habanero | 125000 |
Your job is to determine the total spiciness of Ron's chili after he has finished adding peppers.
입력 :
The first line of input will contain a positive integer N, representing the number of peppers Ron adds to his chili. The next N lines will each contain the name of a pepper Ron has added. Each pepper name will exactly match a name that appears in the table above. Note that more than one pepper of the same name can be added.
출력 :
The output will consist of a positive integer T, representing the total spiciness of Ron's chili.
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 1024MB
입출력 예 :
입력 | 출력 |
4 Poblano Cayenne Thai Poblano |
118000 |
풀이 :
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
fun main() = with(BufferedReader(InputStreamReader(System.`in`))) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
val list = mutableListOf<Pair<String, Int>>()
repeat(readLine().toInt()) {
val cur = readLine()
list += Pair(cur, pepperToScolville(cur))
}
bw.write("${list.sumOf { it.second }}")
bw.flush()
bw.close()
}
fun pepperToScolville(pepper: String): Int {
return when (pepper) {
"Poblano" -> 1500
"Mirasol" -> 6000
"Serrano" -> 15500
"Cayenne" -> 40000
"Thai" -> 75000
else -> 125000
}
}
'백준 > 문제' 카테고리의 다른 글
27494번: 2023년은 검은 토끼의 해 (0) | 2024.07.11 |
---|---|
30957번: 빅데이터 vs 정보보호 vs 인공지능 (0) | 2024.07.10 |
20362번: 유니대전 퀴즈쇼 (0) | 2024.07.09 |
30700번: KOREA 문자열 만들기 (0) | 2024.07.09 |
10928번: SHA-1 (0) | 2024.07.09 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!