結果
| 問題 |
No.580 旅館の予約計画
|
| ユーザー |
|
| 提出日時 | 2024-07-28 04:08:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 2,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 71,168 KB |
| 最終ジャッジ日時 | 2024-07-28 04:08:44 |
| 合計ジャッジ時間 | 4,012 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
## https://yukicoder.me/problems/no/580
def main():
N, M = map(int, input().split())
lists = []
for _ in range(M):
d, hhmmd, o, hhommo = input().split()
d = int(d)
hhd, mmd = map(int, hhmmd.split(":"))
o = int(o)
hho, mmo = map(int, hhommo.split(":"))
s = (d -2 ) * (60 * 24) + hhd * 60 + mmd
g = (o -2 ) * (60 * 24) + hho * 60 + mmo
lists.append((s, g))
lists.sort(key=lambda x : x[1] * 1000000 + x[0])
room_ends = [-2] * N
answer = 0
for s, g in lists:
target_s = -float("inf")
target_n = -1
for n in range(N):
if room_ends[n] < s:
if room_ends[n] > target_s:
target_s = room_ends[n]
target_n = n
if target_n != -1:
room_ends[target_n] = g
answer += 1
print(answer)
if __name__ == '__main__':
main()