結果

問題 No.580 旅館の予約計画
ユーザー wajima_wataru
提出日時 2018-01-04 21:47:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 605 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-23 03:51:23
合計ジャッジ時間 2,409 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 36
権限があれば一括ダウンロードができます

ソースコード

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('[ :]', f.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