結果

問題 No.580 旅館の予約計画
ユーザー wajima_wataruwajima_wataru
提出日時 2018-01-04 21:48:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 9,476 KB
最終ジャッジ日時 2023-08-24 19:02:47
合計ジャッジ時間 2,746 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,128 KB
testcase_01 AC 25 ms
9,232 KB
testcase_02 AC 27 ms
9,180 KB
testcase_03 AC 25 ms
9,136 KB
testcase_04 AC 25 ms
9,228 KB
testcase_05 AC 25 ms
9,172 KB
testcase_06 AC 25 ms
9,152 KB
testcase_07 AC 25 ms
9,148 KB
testcase_08 AC 26 ms
9,188 KB
testcase_09 AC 26 ms
9,152 KB
testcase_10 AC 26 ms
9,240 KB
testcase_11 AC 26 ms
9,332 KB
testcase_12 AC 28 ms
9,284 KB
testcase_13 AC 26 ms
9,316 KB
testcase_14 AC 28 ms
9,180 KB
testcase_15 AC 38 ms
9,284 KB
testcase_16 AC 36 ms
9,412 KB
testcase_17 AC 36 ms
9,316 KB
testcase_18 AC 35 ms
9,412 KB
testcase_19 AC 41 ms
9,420 KB
testcase_20 AC 34 ms
9,276 KB
testcase_21 AC 34 ms
9,400 KB
testcase_22 AC 31 ms
9,352 KB
testcase_23 AC 32 ms
9,344 KB
testcase_24 AC 33 ms
9,320 KB
testcase_25 AC 32 ms
9,320 KB
testcase_26 AC 25 ms
9,180 KB
testcase_27 AC 25 ms
9,296 KB
testcase_28 AC 25 ms
9,180 KB
testcase_29 AC 25 ms
9,232 KB
testcase_30 AC 33 ms
9,312 KB
testcase_31 AC 35 ms
9,312 KB
testcase_32 AC 32 ms
9,324 KB
testcase_33 AC 36 ms
9,476 KB
testcase_34 AC 32 ms
9,360 KB
testcase_35 AC 25 ms
9,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
import heapq

N, M = map(int, input().split())
R = []
for _ in range(M):
    d_in, h_in, m_in, d_out, h_out, m_out = map(int, re.split('[ :]', input()))
    R.append([d_in * 1440 + h_in * 60 + m_in, d_out * 1440 + h_out * 60 + m_out])
R.sort(key=lambda x: x[1])
R.sort(key=lambda x: x[0])
pendings = []
count = 0
for r in R:
    heapq.heappush(pendings, (r[1], r[0]))
    while pendings[0][0] < r[0]:
        heapq.heappop(pendings)
        count += 1
    if len(pendings) > N:
        pendings.sort()
        pendings.pop()
        heapq.heapify(pendings)
count += len(pendings)
print(count)
0