結果
問題 | No.580 旅館の予約計画 |
ユーザー | rutilicus |
提出日時 | 2020-12-17 18:43:15 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 456 ms / 2,000 ms |
コード長 | 1,108 bytes |
コンパイル時間 | 17,414 ms |
コンパイル使用メモリ | 446,236 KB |
実行使用メモリ | 55,016 KB |
最終ジャッジ日時 | 2023-10-21 07:03:19 |
合計ジャッジ時間 | 32,460 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 331 ms
54,408 KB |
testcase_01 | AC | 335 ms
54,404 KB |
testcase_02 | AC | 344 ms
54,436 KB |
testcase_03 | AC | 344 ms
54,492 KB |
testcase_04 | AC | 339 ms
54,484 KB |
testcase_05 | AC | 340 ms
54,492 KB |
testcase_06 | AC | 351 ms
54,544 KB |
testcase_07 | AC | 354 ms
54,544 KB |
testcase_08 | AC | 351 ms
54,540 KB |
testcase_09 | AC | 362 ms
54,612 KB |
testcase_10 | AC | 361 ms
54,612 KB |
testcase_11 | AC | 360 ms
54,612 KB |
testcase_12 | AC | 364 ms
54,660 KB |
testcase_13 | AC | 359 ms
54,612 KB |
testcase_14 | AC | 380 ms
54,704 KB |
testcase_15 | AC | 447 ms
55,016 KB |
testcase_16 | AC | 428 ms
54,880 KB |
testcase_17 | AC | 435 ms
54,880 KB |
testcase_18 | AC | 428 ms
54,880 KB |
testcase_19 | AC | 456 ms
54,976 KB |
testcase_20 | AC | 424 ms
54,876 KB |
testcase_21 | AC | 422 ms
54,864 KB |
testcase_22 | AC | 421 ms
54,864 KB |
testcase_23 | AC | 430 ms
54,880 KB |
testcase_24 | AC | 438 ms
54,884 KB |
testcase_25 | AC | 425 ms
54,872 KB |
testcase_26 | AC | 342 ms
54,496 KB |
testcase_27 | AC | 341 ms
54,496 KB |
testcase_28 | AC | 343 ms
54,496 KB |
testcase_29 | AC | 352 ms
54,496 KB |
testcase_30 | AC | 425 ms
54,876 KB |
testcase_31 | AC | 431 ms
54,880 KB |
testcase_32 | AC | 425 ms
54,864 KB |
testcase_33 | AC | 429 ms
54,980 KB |
testcase_34 | AC | 414 ms
54,872 KB |
testcase_35 | AC | 332 ms
54,484 KB |
コンパイルメッセージ
Main.kt:11: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) ^
ソースコード
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.first } timeList.sortBy { it.second } var ans = 0 val room = IntArray(n) { -1 } for (t in timeList) { var maxIndex = -1 for ((i, r) in room.withIndex()) { if (r <= t.first && (maxIndex == -1 || room[maxIndex] < r)) { maxIndex = i } } if (maxIndex != -1) { room[maxIndex] = t.second ans++ } } builder.appendln(ans) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }