結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 03:48:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 31,940 KB
最終ジャッジ日時 2024-04-19 08:21:21
合計ジャッジ時間 10,785 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 WA -
testcase_02 AC 29 ms
10,752 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 29 ms
10,752 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 313 ms
14,776 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 30 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Tの制約から半分全列挙を考えてしまったが、ただのDPでした。
# これを解けないのは非常にマズい。

N=int(input())
T=int(input())
A=list(map(int,input().split()))

DP=["z"]*(T+1)

DP[A[0]]=""

for i in range(1,N):
    NDP=["z"]*(T+1)
    for j in range(A[0],T+1):
        if DP[j]!="z":
            if j+A[i]<=T:
                NDP[j+A[i]]=min(NDP[j+A[i]],DP[j]+"+")
            if j*A[i]<=T:
                NDP[j*A[i]]=min(NDP[j*A[i]],DP[j]+"*")
    DP=NDP

print(DP[T])
0