結果

問題 No.783 門松計画
ユーザー convexineqconvexineq
提出日時 2021-03-16 10:08:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 686 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,696 KB
最終ジャッジ日時 2024-04-25 10:16:39
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
60,160 KB
testcase_01 AC 45 ms
60,544 KB
testcase_02 AC 44 ms
59,904 KB
testcase_03 AC 40 ms
58,368 KB
testcase_04 AC 40 ms
58,880 KB
testcase_05 AC 46 ms
60,800 KB
testcase_06 AC 43 ms
58,752 KB
testcase_07 AC 44 ms
59,136 KB
testcase_08 AC 41 ms
58,496 KB
testcase_09 AC 44 ms
60,544 KB
testcase_10 RE -
testcase_11 AC 186 ms
77,696 KB
testcase_12 AC 118 ms
74,752 KB
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 41 ms
59,776 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,C = map(int,input().split())
*v, = map(int,input().split())
*w, = map(int,input().split())

N = 51
dp = [[[0]*N for _ in range(N)] for _ in range(C+1)]
for i in range(n):
    for j in range(n):
        if v[i] != v[j]:
            dp[w[i]+w[j]][v[i]][v[j]] = v[i]+v[j]

ans = 0
for i in range(C+1):
    for j in range(N):
        for k in range(N):
            if dp[i][j][k] == 0: continue
            for l in range(n):
                if j == v[l]: continue
                if i+w[l] > C: continue
                if j > k < v[l] or j < k > v[l]:
                    x = dp[i][j][k] + v[l]
                    ans = max(ans,x)
                    dp[i+w[l]][k][v[l]] = x
print(ans)
0