結果

問題 No.783 門松計画
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 15:02:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,013 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 175,032 KB
最終ジャッジ日時 2023-09-24 14:00:12
合計ジャッジ時間 7,368 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,860 KB
testcase_01 AC 72 ms
71,108 KB
testcase_02 AC 75 ms
74,592 KB
testcase_03 AC 78 ms
71,304 KB
testcase_04 AC 74 ms
71,216 KB
testcase_05 AC 72 ms
70,824 KB
testcase_06 AC 74 ms
71,360 KB
testcase_07 AC 75 ms
71,260 KB
testcase_08 AC 75 ms
71,332 KB
testcase_09 AC 75 ms
71,260 KB
testcase_10 AC 381 ms
91,592 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

# list 多重リスト生成
def dlist(*l, fill=None):
    if len(l)==1:
        return [fill]*l[0]
    ll = l[1:]
    return [dlist(*ll, fill=fill) for _ in range(l[0])]
n,c = list(map(int, input().split()))
l = list(map(int, input().split()))
w = list(map(int, input().split()))
dp = {(-1,-1,0): 0}
ans = 0
while dp:
    ndp = {}
    for (i,j,k),val in dp.items():
        for ii in range(n):
            ll = l[ii]
            ww = w[ii]
            if ll==i or ll==j or ww+k>c:
                continue
            if i!=-1 and j!=-1:
                if (j-i)*(ll-j)>0:
                    continue
                ans = max(ans, val+ll)
            nk = (j,ll,ww+k)
            ndp.setdefault(nk, 0)
            ndp[nk] = max(ndp[nk], val+ll)
    dp = ndp
#     print(dp)
print(ans)
0