[백준/코틀린] 2798번: 블랙잭
브론즈 2
링크
풀이
생략
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fun main() {
val (n, m) = readln().split(" ").map { it.toInt() }
val cards = readln().split(" ").map { it.toInt() }
var ans = 0
for (i in 0..n - 3) {
for (j in i + 1..n - 2) {
for (k in j + 1..n - 1) {
val sum = cards[i] + cards[j] + cards[k]
if (sum <= m) {
ans = maxOf(ans, sum)
}
}
}
}
println(ans)
}
This post is licensed under CC BY 4.0 by the author.