結果

問題 No.974 最後の日までに
ユーザー maspymaspy
提出日時 2020-04-01 01:08:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,165 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 160,168 KB
最終ジャッジ日時 2023-09-07 22:09:41
合計ジャッジ時間 78,089 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 933 ms
160,168 KB
testcase_01 TLE -
testcase_02 TLE -
testcase_03 AC 1,993 ms
159,884 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 1,983 ms
155,956 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,978 ms
157,884 KB
testcase_16 AC 1,975 ms
158,188 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 82 ms
75,864 KB
testcase_26 AC 86 ms
75,764 KB
testcase_27 AC 1,617 ms
138,268 KB
testcase_28 TLE -
testcase_29 AC 71 ms
71,080 KB
testcase_30 TLE -
testcase_31 AC 70 ms
71,136 KB
testcase_32 AC 71 ms
71,396 KB
testcase_33 AC 1,276 ms
125,588 KB
testcase_34 TLE -
testcase_35 AC 73 ms
71,256 KB
testcase_36 AC 72 ms
71,252 KB
testcase_37 TLE -
testcase_38 AC 74 ms
71,560 KB
testcase_39 AC 73 ms
71,348 KB
testcase_40 AC 1,266 ms
139,996 KB
testcase_41 AC 1,639 ms
157,264 KB
testcase_42 TLE -
testcase_43 TLE -
testcase_44 AC 1,608 ms
138,216 KB
testcase_45 AC 1,305 ms
125,800 KB
testcase_46 AC 72 ms
71,236 KB
testcase_47 AC 73 ms
71,472 KB
testcase_48 AC 73 ms
71,292 KB
testcase_49 AC 73 ms
71,236 KB
testcase_50 AC 74 ms
71,248 KB
testcase_51 AC 73 ms
71,136 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