Skip to content

Commit

Permalink
solve(BOJ): G5_11509_풍선_맞추기_kt
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumaC committed Jan 7, 2024
1 parent 7af1eb1 commit 80da625
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/boj/G5_11509_풍선_맞추기.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package boj

class BOJ11509() {

lateinit var balloons: MutableList<Int>

fun solve() {
val n = readln().toInt()
balloons = readln().split(" ").map { it.toInt() }.toMutableList()
val arrows = mutableListOf<Int>()
for (i in 0 until n) {
val balloonHeight = balloons[i]
val arrowIndex = arrows.indexOf(balloonHeight)
if (arrowIndex >= 0) {
arrows[arrowIndex]--
} else {
arrows.add(balloonHeight - 1)
}
}

print(arrows.size)
}
}

fun main() {
BOJ11509().solve()
}

0 comments on commit 80da625

Please sign in to comment.