반응형
https://www.acmicpc.net/problem/11047
fun main() {
var result = 0
val sc: Scanner = Scanner(System.`in`)
var (coin, price) = readLine()!!.split(' ').map(String::toInt)
var coinList = arrayOfNulls<Int>(coin)
for (i in 0..coinList.lastIndex) {
coinList[i] = sc.nextLine().toInt()
}
for (j in (coin - 1) downTo 0) {
if(price / coinList[j]!! != 0) {
result += price / coinList[j]!!
price %= coinList[j]!!
}
}
println(result)
}
반응형