結果
問題 |
No.580 旅館の予約計画
|
ユーザー |
![]() |
提出日時 | 2018-01-04 21:48:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 603 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-12-23 03:51:26 |
合計ジャッジ時間 | 2,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
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)