結果

問題 No.580 旅館の予約計画
ユーザー rutilicusrutilicus
提出日時 2020-12-17 18:27:59
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 30,067 ms
コンパイル使用メモリ 445,068 KB
実行使用メモリ 55,308 KB
最終ジャッジ日時 2023-10-21 07:02:20
合計ジャッジ時間 35,512 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
51,204 KB
testcase_01 AC 331 ms
52,312 KB
testcase_02 AC 331 ms
54,552 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 345 ms
54,656 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 416 ms
54,972 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 337 ms
54,596 KB
testcase_27 AC 341 ms
54,612 KB
testcase_28 AC 329 ms
54,604 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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