結果

問題 No.783 門松計画
ユーザー vwxyzvwxyz
提出日時 2022-04-09 15:53:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 697 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 14,904 KB
最終ジャッジ日時 2023-08-19 19:48:27
合計ジャッジ時間 4,445 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,232 KB
testcase_01 AC 17 ms
7,840 KB
testcase_02 AC 17 ms
8,296 KB
testcase_03 AC 15 ms
8,356 KB
testcase_04 AC 16 ms
8,348 KB
testcase_05 AC 16 ms
8,212 KB
testcase_06 AC 16 ms
8,128 KB
testcase_07 AC 16 ms
8,128 KB
testcase_08 AC 16 ms
8,192 KB
testcase_09 AC 16 ms
8,256 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
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
readline=sys.stdin.readline

N,C=map(int,readline().split())
L=list(map(int,readline().split()))
W=list(map(int,readline().split()))
inf=1<<10
dp=[-inf]*(N*N*(C+1))
for i in range(N):
    for j in range(N):
        for k in range(N):
            if W[i]+W[j]+W[k]<=C and L[i]!=L[k] and (L[i]-L[j])*(L[k]-L[j])>0:
                dp[(W[i]+W[j]+W[k])*N*N+j*N+k]=L[i]+L[j]+L[k]
for c in range(C+1):
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if L[i]!=L[k] and (L[i]-L[j])*(L[k]-L[j])>0 and c+W[k]<=C:
                    dp[(c+W[k])*N*N+j*N+k]=max(dp[(c+W[k])*N*N+j*N+k],dp[c*N*N+i*N+j]+L[k])
ans=max(dp)
if ans<0:
    ans=0
print(ans)
0