結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,376 KB
testcase_01 AC 71 ms
71,356 KB
testcase_02 AC 74 ms
75,124 KB
testcase_03 AC 72 ms
71,444 KB
testcase_04 AC 73 ms
71,420 KB
testcase_05 AC 72 ms
70,988 KB
testcase_06 AC 73 ms
71,264 KB
testcase_07 AC 75 ms
71,360 KB
testcase_08 AC 74 ms
71,092 KB
testcase_09 AC 73 ms
71,440 KB
testcase_10 AC 357 ms
91,784 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()))
index = list(range(n))
index.sort(key=lambda i: w[i])
l = [l[i] for i in index]
w = [w[i] for i in index]
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 ww+k>c:
                break
            if ll==i or ll==j:
                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