結果
| 問題 |
No.1373 Directed Operations
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-24 11:31:44 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 947 ms / 2,000 ms |
| コード長 | 641 bytes |
| コンパイル時間 | 15,998 ms |
| コンパイル使用メモリ | 437,260 KB |
| 実行使用メモリ | 93,676 KB |
| 最終ジャッジ日時 | 2024-07-19 15:53:43 |
| 合計ジャッジ時間 | 30,071 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
import java.util.*
import kotlin.system.exitProcess
fun main() {
val n = readLine()!!.toInt()
val a = readLine()!!.split(" ").map { it.toInt() }
val ord = a.zip(0 until n - 1).sortedBy { it.first }
var ans = MutableList(n - 1) { 0 }
var pos = 0
val queue = LinkedList<Pair<Int, Int>>()
for (i in 2..n) {
while (pos < n - 1 && ord[pos].first == i - 1) queue.add(ord[pos++])
if (queue.isEmpty()) {
println("NO")
exitProcess(0)
}
val (value, index) = queue.poll()!!
ans[index] = i - value
}
println("YES")
println(ans.joinToString("\n"))
}