結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 908 ms
160,588 KB
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 1,962 ms
159,148 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,978 ms
158,888 KB
testcase_09 AC 1,989 ms
159,284 KB
testcase_10 TLE -
testcase_11 AC 1,954 ms
156,272 KB
testcase_12 AC 1,954 ms
159,368 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,930 ms
158,324 KB
testcase_16 AC 1,938 ms
158,416 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 78 ms
76,184 KB
testcase_26 AC 83 ms
75,940 KB
testcase_27 AC 1,530 ms
138,544 KB
testcase_28 TLE -
testcase_29 AC 65 ms
71,528 KB
testcase_30 TLE -
testcase_31 AC 68 ms
71,184 KB
testcase_32 AC 69 ms
71,136 KB
testcase_33 AC 1,231 ms
125,800 KB
testcase_34 TLE -
testcase_35 AC 67 ms
71,340 KB
testcase_36 AC 69 ms
71,324 KB
testcase_37 TLE -
testcase_38 AC 74 ms
71,404 KB
testcase_39 AC 75 ms
71,284 KB
testcase_40 AC 1,289 ms
140,352 KB
testcase_41 AC 1,595 ms
157,360 KB
testcase_42 TLE -
testcase_43 TLE -
testcase_44 AC 1,657 ms
138,264 KB
testcase_45 AC 1,253 ms
125,740 KB
testcase_46 AC 66 ms
71,288 KB
testcase_47 AC 68 ms
71,404 KB
testcase_48 AC 67 ms
71,140 KB
testcase_49 AC 67 ms
71,292 KB
testcase_50 AC 69 ms
71,364 KB
testcase_51 AC 69 ms
71,296 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