結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 03:49:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,743 ms / 5,000 ms
コード長 521 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 31,668 KB
最終ジャッジ日時 2023-08-21 06:35:18
合計ジャッジ時間 11,233 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,876 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 15 ms
7,720 KB
testcase_03 AC 3,743 ms
31,660 KB
testcase_04 AC 548 ms
10,236 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 3,632 ms
31,668 KB
testcase_07 AC 1,491 ms
23,388 KB
testcase_08 AC 307 ms
12,800 KB
testcase_09 AC 366 ms
12,912 KB
testcase_10 AC 18 ms
7,784 KB
testcase_11 AC 16 ms
7,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

DP=[chr(0)]*(T+1)

DP[A[0]]=""

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

print(DP[T])
0