結果

問題 No.783 門松計画
ユーザー mkawa2mkawa2
提出日時 2021-02-11 14:55:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 17,328 KB
最終ジャッジ日時 2023-09-25 04:13:22
合計ジャッジ時間 4,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
8,684 KB
testcase_01 AC 42 ms
9,108 KB
testcase_02 AC 26 ms
8,640 KB
testcase_03 AC 18 ms
8,448 KB
testcase_04 AC 19 ms
8,408 KB
testcase_05 AC 24 ms
8,620 KB
testcase_06 AC 21 ms
8,448 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 24 ms
8,576 KB
testcase_10 AC 402 ms
9,536 KB
testcase_11 TLE -
testcase_12 AC 1,123 ms
9,660 KB
testcase_13 AC 122 ms
9,568 KB
testcase_14 AC 150 ms
9,752 KB
testcase_15 AC 32 ms
8,760 KB
testcase_16 AC 25 ms
8,680 KB
testcase_17 AC 53 ms
9,544 KB
testcase_18 AC 22 ms
8,540 KB
testcase_19 AC 65 ms
9,244 KB
testcase_20 AC 29 ms
8,788 KB
testcase_21 AC 25 ms
8,652 KB
testcase_22 WA -
testcase_23 AC 30 ms
8,676 KB
testcase_24 AC 57 ms
8,908 KB
testcase_25 AC 34 ms
8,836 KB
testcase_26 AC 64 ms
9,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**16
# md = 998244353
# md = 10**9+7

n,c=MI()
ll=LI()
ww=LI()

# dp[i][j][k]...i金額、j,k最後の2本

dp=[[[-1]*51 for _ in range(51)] for _ in range(c+1)]

def chmax(i,j,k,val):
    if i>c or j>50 or k>50:return
    if val>dp[i][j][k]:dp[i][j][k]=val

dp[0][0][0]=0
for i in range(c):
    for j in range(51):
        for k in range(51):
            pre=dp[i][j][k]
            if pre==-1:continue
            for l,w in zip(ll,ww):
                if k==0:chmax(i+w,j,l,l)
                elif j==0:
                    if l!=k:chmax(i+w,k,l,pre+l)
                elif j<k:
                    if l<k and l!=j:
                        chmax(i+w,k,l,pre+l)
                else:
                    if l>k and l!=j:
                        chmax(i+w,k,l,pre+l)

ans=max(dp[i][j][k] for i in range(c+1) for j in range(1,51) for k in range(51))
print(0 if ans==-1 else ans)
0