結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 03:49:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 4,092 ms / 5,000 ms
コード長 521 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 31,732 KB
最終ジャッジ日時 2024-12-14 15:49:09
合計ジャッジ時間 12,371 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,496 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 4,092 ms
31,732 KB
testcase_04 AC 613 ms
12,704 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 4,067 ms
31,520 KB
testcase_07 AC 1,672 ms
24,008 KB
testcase_08 AC 358 ms
15,424 KB
testcase_09 AC 421 ms
14,896 KB
testcase_10 AC 33 ms
10,752 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=[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