fun main() { val builder = StringBuilder() // 区間スケジューリングの使い方分からない…… val (n, m) = readInputLine().split(" ").map { it.toInt() } val timeList = mutableListOf>() 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()!! }