結果

問題 No.580 旅館の予約計画
ユーザー maspy
提出日時 2020-02-28 01:36:36
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 23 ms / 2,000 ms
+ 464µs
コード長 839 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2026-09-15 20:21:10
合計ジャッジ時間 2,851 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter
from bisect import bisect_left

# %%
N, M = map(int, readline().split())
lines = readlines()

# %%
LR = []
for line in lines:
    day1, hm1, day2, hm2 = line.split()
    h1, m1 = hm1.split(b':')
    h2, m2 = hm2.split(b':')
    L = int(day1) * 1440 + int(h1) * 60 + int(m1)
    R = int(day2) * 1440 + int(h2) * 60 + int(m2)
    LR.append((L, R))
LR.sort(key=itemgetter(1))
# %%
answer = 0
end_times = []
for L, R in LR:
    i = bisect_left(end_times, L)
    if i:
        del end_times[i - 1]
        end_times.append(R)
        answer += 1
    elif len(end_times) < N:
        end_times.append(R)
        answer += 1
        continue


# %%
print(answer)


# %%
0