結果

問題 No.783 門松計画
ユーザー titiatitia
提出日時 2024-02-03 03:15:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 2,053 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 83,524 KB
最終ジャッジ日時 2024-02-03 03:16:02
合計ジャッジ時間 4,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 38 ms
53,460 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 #

N,C=map(int,input().split())
L=list(map(int,input().split()))
W=list(map(int,input().split()))

def calc(a,b,cost):
    ANS=0
    if a==b==0:
        for i in range(N):
            if W[i]<=cost:
                ANS=max(ANS,L[i]+calc(0,L[i],cost-W[i]))

        return ANS

    if a==0:
        for i in range(N):
            if L[i]!=b and W[i]<=cost:
                ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))

        return ANS

    if a<b:
        for i in range(N):
            if W[i]<=cost and L[i]<b and L[i]!=a:
                ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))
        return ANS
    else:
        for i in range(N):
            if W[i]<=cost and L[i]>b and L[i]!=a:
                ANS=max(ANS,L[i]+calc(b,L[i],cost-W[i]))
        return ANS

if len(set(sorted(L)))<=2:
    print(0)
else:
    print(calc(0,0,C))
0