結果
問題 | No.580 旅館の予約計画 |
ユーザー | Theta |
提出日時 | 2022-12-16 13:15:40 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 2,191 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-04-27 15:24:55 |
合計ジャッジ時間 | 2,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,752 KB |
testcase_01 | AC | 29 ms
10,752 KB |
testcase_02 | AC | 28 ms
11,008 KB |
testcase_03 | AC | 29 ms
11,008 KB |
testcase_04 | AC | 27 ms
11,008 KB |
testcase_05 | AC | 28 ms
10,880 KB |
testcase_06 | AC | 30 ms
10,880 KB |
testcase_07 | AC | 36 ms
11,136 KB |
testcase_08 | AC | 28 ms
10,880 KB |
testcase_09 | AC | 29 ms
11,008 KB |
testcase_10 | AC | 30 ms
10,880 KB |
testcase_11 | AC | 34 ms
11,008 KB |
testcase_12 | AC | 38 ms
10,880 KB |
testcase_13 | AC | 34 ms
11,008 KB |
testcase_14 | AC | 38 ms
10,880 KB |
testcase_15 | AC | 88 ms
11,392 KB |
testcase_16 | AC | 63 ms
11,264 KB |
testcase_17 | AC | 61 ms
11,136 KB |
testcase_18 | AC | 63 ms
11,136 KB |
testcase_19 | AC | 85 ms
11,392 KB |
testcase_20 | AC | 51 ms
11,136 KB |
testcase_21 | AC | 54 ms
11,136 KB |
testcase_22 | AC | 39 ms
11,264 KB |
testcase_23 | AC | 42 ms
11,136 KB |
testcase_24 | AC | 48 ms
11,264 KB |
testcase_25 | AC | 46 ms
11,008 KB |
testcase_26 | AC | 31 ms
10,880 KB |
testcase_27 | AC | 29 ms
11,136 KB |
testcase_28 | AC | 28 ms
10,880 KB |
testcase_29 | AC | 29 ms
11,136 KB |
testcase_30 | AC | 46 ms
11,136 KB |
testcase_31 | AC | 56 ms
11,136 KB |
testcase_32 | AC | 42 ms
11,264 KB |
testcase_33 | AC | 78 ms
11,136 KB |
testcase_34 | AC | 41 ms
11,136 KB |
testcase_35 | AC | 28 ms
11,008 KB |
ソースコード
from functools import total_ordering @total_ordering class OrderTime: def __init__(self, day: int, hour: int, minute: int) -> None: self.hour = hour self.minute = minute self.day = day @property def time_tuple(self) -> tuple[int, int, int]: return self.day, self.hour, self.minute def __eq__(self, __o: object) -> bool: if not isinstance(__o, OrderTime): raise ValueError return self.time_tuple == __o.time_tuple def __lt__(self, __o: object) -> bool: if not isinstance(__o, OrderTime): raise ValueError return self.time_tuple < __o.time_tuple def __str__(self) -> str: return f"{self.day} {self.hour}:{self.minute}" class Order: def __init__(self, enter_day, enter_hour, enter_minute, out_day, out_hour, out_minute) -> None: self.enter_time = OrderTime(enter_day, enter_hour, enter_minute) self.out_time = OrderTime(out_day, out_hour, out_minute) def can_stay(self, _o: object) -> bool: if not isinstance(_o, Order): raise ValueError return self.out_time < _o.enter_time def main(): n, m = map(int, input().split()) orders: list[Order] = [] for _ in range(m): enter_day, enter_time, out_day, out_time = input().split() enter_day = int(enter_day) out_day = int(out_day) enter_hour, enter_minute = map(int, enter_time.split(":")) out_hour, out_minute = map(int, out_time.split(":")) orders.append(Order(enter_day, enter_hour, enter_minute, out_day, out_hour, out_minute)) orders.sort(key=lambda order: order.out_time) ctr = 0 rooms = [Order(1, 23, 50, 1, 23, 59) for _ in range(n)] for order in orders: next_order = [-1, (-1, -1, -1)] for room_idx, room in enumerate(rooms): if room.can_stay(order) and next_order[1] < room.out_time.time_tuple: next_order = [room_idx, room.out_time.time_tuple] if next_order[0] == -1: continue rooms[next_order[0]] = order ctr += 1 print(ctr) if __name__ == "__main__": main()