結果

問題 No.783 門松計画
ユーザー shotoyooshotoyoo
提出日時 2021-07-22 15:19:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 1,226 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 80,324 KB
最終ジャッジ日時 2023-09-24 14:03:16
合計ジャッジ時間 5,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
78,972 KB
testcase_01 AC 133 ms
78,896 KB
testcase_02 AC 135 ms
78,508 KB
testcase_03 AC 91 ms
76,852 KB
testcase_04 AC 120 ms
78,428 KB
testcase_05 AC 136 ms
78,984 KB
testcase_06 AC 127 ms
78,312 KB
testcase_07 AC 119 ms
78,292 KB
testcase_08 AC 111 ms
78,160 KB
testcase_09 AC 140 ms
78,888 KB
testcase_10 AC 225 ms
80,140 KB
testcase_11 AC 310 ms
80,072 KB
testcase_12 AC 269 ms
80,020 KB
testcase_13 AC 193 ms
80,324 KB
testcase_14 AC 201 ms
80,016 KB
testcase_15 AC 158 ms
79,524 KB
testcase_16 AC 144 ms
79,208 KB
testcase_17 AC 183 ms
80,100 KB
testcase_18 AC 110 ms
78,280 KB
testcase_19 AC 190 ms
79,800 KB
testcase_20 AC 120 ms
78,336 KB
testcase_21 AC 126 ms
78,592 KB
testcase_22 AC 125 ms
78,540 KB
testcase_23 AC 92 ms
76,708 KB
testcase_24 AC 164 ms
79,680 KB
testcase_25 AC 159 ms
79,608 KB
testcase_26 AC 188 ms
79,904 KB
権限があれば一括ダウンロードができます

ソースコード

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]
inf = 10**12
dp = dlist(51,51,c+1,fill=-inf)
dp[0][0][0] = 0
ans = 0
for k in range(c+1):
    for i in range(51):
        for j in range(51):
            val = dp[i][j][k]
            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!=0 and j!=0:
                    if (j-i)*(ll-j)>0:
                        continue
                    ans = max(ans, val+ll)
                dp[j][ll][ww+k] = max(dp[j][ll][ww+k], val+ll)
#     print(dp)
print(ans)
0