結果

問題 No.580 旅館の予約計画
ユーザー rlangevin
提出日時 2024-01-12 08:56:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 68,124 KB
最終ジャッジ日時 2024-09-27 20:46:42
合計ジャッジ時間 2,996 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def f(d, hm):
    d = int(d)
    h, m = map(int, hm.split(":"))
    return d * 1440 + h * 60 + m

N, M = map(int, input().split())
D = []
for i in range(M):
    d1, hm1, d2, hm2 = input().split()
    D.append((f(d2, hm2), f(d1, hm1)))
    
D.sort()
ans = 0
now = [-1] * N
for r, l in D:
    ind = -1
    maxv = -10
    for i in range(N):
        if now[i] < l and now[i] > maxv:
            ind = i
            maxv = now[i]
    if ind == -1:
        continue
    ans += 1
    now[ind] = r
    
print(ans)
0