結果

問題 No.580 旅館の予約計画
ユーザー mkawa2
提出日時 2020-01-05 14:30:34
言語 Python3
(3.8.1 + numpy 1.14.5 + scipy 1.1.0)
結果
WA   .
実行時間 -
コード長 2,096 Byte
コンパイル時間 52 ms
使用メモリ 27,884 KB
最終ジャッジ日時 2020-01-05 14:30:43

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
input00.txt AC 136 ms
27,672 KB
input01.txt AC 132 ms
27,624 KB
input02.txt AC 132 ms
27,608 KB
input03.txt WA -
input04.txt WA -
input05.txt AC 244 ms
27,432 KB
input06.txt AC 228 ms
27,472 KB
input07.txt AC 204 ms
27,412 KB
input08.txt AC 156 ms
27,460 KB
input09.txt WA -
input10.txt WA -
input11.txt AC 140 ms
27,528 KB
input12.txt WA -
input13.txt AC 144 ms
27,452 KB
input14.txt WA -
input15.txt WA -
input16.txt WA -
input17.txt WA -
input18.txt WA -
input19.txt AC 284 ms
27,632 KB
input20.txt WA -
input21.txt WA -
input22.txt AC 144 ms
27,640 KB
input23.txt WA -
input24.txt WA -
input25.txt WA -
input26.txt AC 224 ms
27,496 KB
input27.txt AC 224 ms
27,336 KB
input28.txt WA -
input29.txt WA -
input30.txt WA -
input31.txt WA -
input32.txt WA -
input33.txt WA -
input34.txt WA -
input35.txt AC 132 ms
27,468 KB
テストケース一括ダウンロード

ソースコード

diff #
from itertools import *
from bisect import *
# from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    def stod(s):
        res=int(s[0])*10000+int(s[2:4])*100+int(s[5:7])
        return res

    n, m = MI()
    if n > m:
        print(m)
        exit()
    reserve = []
    for _ in range(m):
        s = input()
        date0=stod(s[:7])
        date1=stod(s[8:])
        heappush(reserve, [date1,date0])

    ans = 0
    for _ in range(n):
        if not reserve:break
        room=[]
        pending=[]
        date1,date0=heappop(reserve)
        room.append([date1,date0])
        checkout=date1
        ans+=1
        while reserve:
            date1, date0 = heappop(reserve)
            if date0>checkout:
                room.append([date1, date0])
                checkout=date1
                ans+=1
            else:
                heappush(pending,[date0,date1])

        date1,date0=room.pop()
        heappush(pending, [date0, date1])
        if room:
            checkout=room[-1][0]
            while pending:
                date0,date1=heappop(pending)
                if date0>checkout:
                    break
                else:
                    heappush(reserve,[date1,date0])
        else:
            heappop(pending)

        while pending:
            date0, date1 = heappop(pending)
            heappush(reserve, [date1, date0])

    print(ans)

main()
0