Skip to content

Commit

Permalink
한 줄로 서기
Browse files Browse the repository at this point in the history
그리디 알고리즘
  • Loading branch information
yewon-yw authored Jan 30, 2025
1 parent 57e1e77 commit 516f073
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions greedy_algorithm/1138.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package boj

fun main() = with(System.`in`.bufferedReader()) {
val n = readLine().toInt()
val line = IntArray(n)
readLine().split(' ').map { it.toInt() }.forEachIndexed { idx, v ->
var count = 0
for (i in 0..<n) {
if (line[i] == 0) {
if (count == v) {
line[i] = idx + 1
break
}
count++
}
}
}
println(line.joinToString(" "))
}

0 comments on commit 516f073

Please sign in to comment.