結果
問題 | No.580 旅館の予約計画 |
ユーザー | mkawa2 |
提出日時 | 2020-01-05 14:30:34 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,096 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 10,892 KB |
実行使用メモリ | 30,256 KB |
最終ジャッジ日時 | 2023-08-14 21:02:40 |
合計ジャッジ時間 | 7,978 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 136 ms
29,904 KB |
testcase_01 | AC | 136 ms
29,924 KB |
testcase_02 | AC | 136 ms
30,088 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 137 ms
30,072 KB |
testcase_06 | AC | 136 ms
29,920 KB |
testcase_07 | AC | 138 ms
29,984 KB |
testcase_08 | AC | 137 ms
30,012 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 140 ms
29,964 KB |
testcase_12 | WA | - |
testcase_13 | AC | 139 ms
29,932 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 263 ms
30,172 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 143 ms
30,044 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 134 ms
29,832 KB |
testcase_27 | AC | 138 ms
29,900 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 137 ms
29,884 KB |
ソースコード
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()