結果

問題 No.580 旅館の予約計画
ユーザー mitsuomitsuo
提出日時 2018-08-22 10:16:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 1,351 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 10,280 KB
最終ジャッジ日時 2023-08-25 00:48:38
合計ジャッジ時間 7,211 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,880 KB
testcase_01 AC 27 ms
9,764 KB
testcase_02 AC 28 ms
9,784 KB
testcase_03 AC 43 ms
9,832 KB
testcase_04 AC 50 ms
9,928 KB
testcase_05 AC 44 ms
9,824 KB
testcase_06 AC 55 ms
10,172 KB
testcase_07 AC 111 ms
9,780 KB
testcase_08 AC 55 ms
9,876 KB
testcase_09 AC 44 ms
9,896 KB
testcase_10 AC 58 ms
9,772 KB
testcase_11 AC 78 ms
9,832 KB
testcase_12 AC 46 ms
9,912 KB
testcase_13 AC 33 ms
9,964 KB
testcase_14 AC 29 ms
9,924 KB
testcase_15 AC 509 ms
10,260 KB
testcase_16 AC 409 ms
10,280 KB
testcase_17 AC 311 ms
10,112 KB
testcase_18 AC 260 ms
10,208 KB
testcase_19 AC 216 ms
10,104 KB
testcase_20 AC 273 ms
10,104 KB
testcase_21 AC 237 ms
10,172 KB
testcase_22 AC 199 ms
10,168 KB
testcase_23 AC 245 ms
10,092 KB
testcase_24 AC 263 ms
10,092 KB
testcase_25 AC 131 ms
10,096 KB
testcase_26 AC 33 ms
9,820 KB
testcase_27 AC 33 ms
9,888 KB
testcase_28 AC 32 ms
9,952 KB
testcase_29 AC 32 ms
9,768 KB
testcase_30 AC 110 ms
10,088 KB
testcase_31 AC 345 ms
10,168 KB
testcase_32 AC 184 ms
10,120 KB
testcase_33 AC 325 ms
10,092 KB
testcase_34 AC 66 ms
10,168 KB
testcase_35 AC 21 ms
9,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, m, guestdata):
    schedulenote = {(d,h,m) : 0
                for d in range(2, 9)
                for h in range(0, 24)
                for m in range(0, 60)}
    schedulelist = [(d,h,m)
                for d in range(2, 9)
                for h in range(0, 24)
                for m in range(0, 60)]
    totalcount = 0
    guestdata.sort(key=lambda x: x.split(" ")[2:])

    for guest in guestdata:
        d = guest.split(" ")
        checkin_day = int(d[0])
        checkin_h = int(d[1][:2])
        checkin_m = int(d[1][3:])
        checkout_day = int(d[2])
        checkout_h = int(d[3][:2])
        checkout_m = int(d[3][3:])

        checkin = (checkin_day, checkin_h, checkin_m)
        checkout = (checkout_day, checkout_h, checkout_m)
        available = True

        target_schedule = schedulelist[schedulelist.index(checkin):schedulelist.index(checkout) + 1]

        for schedule in target_schedule:
            if schedulenote[schedule] >= n:
                available = False
                break

        if available:
            totalcount += 1
            for schedule in target_schedule:
                schedulenote[schedule] += 1

    return totalcount

if __name__ == "__main__":
    l = input().split(" ")
    n, m = int(l[0]), int(l[1])
    data = [input() for _ in range(0, m)]
    print(solve(n, m, data))
0