結果

問題 No.580 旅館の予約計画
ユーザー rutilicusrutilicus
提出日時 2020-12-17 18:27:59
言語 Kotlin
(2.1.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 16,822 ms
コンパイル使用メモリ 443,252 KB
実行使用メモリ 57,828 KB
最終ジャッジ日時 2024-09-21 08:10:26
合計ジャッジ時間 28,819 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:10:17: warning: name shadowed: m
        val (h, m) = hm.split(":")
                ^
Main.kt:37:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(ans)
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val (n, m) = readInputLine().split(" ").map { it.toInt() }

    val timeList = mutableListOf<Pair<Int, Int>>()

    repeat(m) {
        val (d, hm, o, hmo) = readInputLine().split(" ")
        val (h, m) = hm.split(":")
        val (ho, mo) = hmo.split(":")
        timeList.add(Pair(d.toInt() * 24 * 60 + h.toInt() * 60 + m.toInt(),
                          o.toInt() * 24 * 60 + ho.toInt() * 60 + mo.toInt() + 1))
    }

    timeList.sortBy { it.second }

    var ans = 0

    val room = IntArray(n) { -1 }

    for (t in timeList) {
        for ((i, r) in room.withIndex()) {
            if (r <= t.first) {
                room[i] = -1
            }
        }
        for ((i, r) in room.withIndex()) {
            if (r == -1) {
                room[i] = t.second
                ans++
                break
            }
        }
    }

    builder.appendln(ans)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0