結果

問題 No.974 最後の日までに
ユーザー maspymaspy
提出日時 2020-04-01 01:08:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,165 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 11,120 KB
実行使用メモリ 121,352 KB
最終ジャッジ日時 2023-09-07 22:04:10
合計ジャッジ時間 48,082 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,156 ms
117,496 KB
testcase_01 AC 1,920 ms
120,972 KB
testcase_02 AC 1,976 ms
120,424 KB
testcase_03 AC 1,918 ms
120,800 KB
testcase_04 AC 1,820 ms
120,788 KB
testcase_05 TLE -
testcase_06 AC 1,978 ms
121,352 KB
testcase_07 AC 1,911 ms
120,736 KB
testcase_08 AC 1,857 ms
120,748 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 1,936 ms
120,136 KB
testcase_12 AC 1,874 ms
120,348 KB
testcase_13 TLE -
testcase_14 AC 1,943 ms
118,284 KB
testcase_15 AC 1,849 ms
120,160 KB
testcase_16 AC 1,829 ms
120,252 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 AC 18 ms
8,272 KB
testcase_26 AC 18 ms
8,492 KB
testcase_27 AC 1,379 ms
68,184 KB
testcase_28 AC 1,928 ms
105,324 KB
testcase_29 AC 16 ms
8,360 KB
testcase_30 TLE -
testcase_31 AC 16 ms
8,328 KB
testcase_32 AC 16 ms
8,332 KB
testcase_33 AC 1,201 ms
77,476 KB
testcase_34 TLE -
testcase_35 AC 15 ms
8,248 KB
testcase_36 AC 15 ms
8,320 KB
testcase_37 TLE -
testcase_38 AC 16 ms
8,428 KB
testcase_39 AC 16 ms
8,428 KB
testcase_40 AC 899 ms
48,988 KB
testcase_41 AC 1,187 ms
75,160 KB
testcase_42 TLE -
testcase_43 TLE -
testcase_44 AC 1,754 ms
76,852 KB
testcase_45 AC 1,329 ms
77,256 KB
testcase_46 AC 16 ms
8,312 KB
testcase_47 AC 15 ms
8,324 KB
testcase_48 AC 15 ms
8,372 KB
testcase_49 AC 36 ms
8,420 KB
testcase_50 AC 15 ms
8,376 KB
testcase_51 AC 16 ms
8,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = int(readline())
m = map(int, read().split())
ABC = tuple(zip(m, m, m))


def gen_all_patterns(L, R):
    """L 日目約束なしの状態から、R日目約束なしの状態へ"""
    n = R - L
    dp = [[] for _ in range(n + 1)]
    dp[0] = [(0, 0)]
    for i, (a, b, c) in enumerate(ABC[L:R]):
        dp[i + 1] += [(x + a, y) for x, y in dp[i]]
        if i:
            dp[i + 1] += [(x - c, y + b) for x, y in dp[i - 1]]
    P = dp[-1]
    P.sort()
    Q = []
    for x, y in P:
        while Q and Q[-1][0] <= x and Q[-1][1] <= y:
            Q.pop()
        Q.append((x, y))
    return Q


def solve(n):
    """ n日目約束なしを経由するパターンを解く """
    P = gen_all_patterns(0, n)[::-1]
    Q = gen_all_patterns(n, W)[::-1]
    for qx, qy in Q:
        while P and P[-1][0] + qx < 0:
            P.pop()
        if not P:
            return
        yield P[-1][1] + qy


answer = 0
for n in range(W // 2, W // 2 + 2):
    x = max(solve(n))
    if answer < x:
        answer = x
print(answer)
0