結果

問題 No.10 +か×か
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-12 22:16:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 116,184 KB
最終ジャッジ日時 2023-08-21 06:33:53
合計ジャッジ時間 2,234 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,044 KB
testcase_01 AC 74 ms
71,276 KB
testcase_02 AC 68 ms
71,248 KB
testcase_03 AC 165 ms
115,856 KB
testcase_04 AC 111 ms
102,240 KB
testcase_05 AC 70 ms
70,956 KB
testcase_06 AC 169 ms
116,184 KB
testcase_07 AC 123 ms
102,396 KB
testcase_08 AC 93 ms
83,692 KB
testcase_09 AC 97 ms
90,616 KB
testcase_10 AC 76 ms
75,736 KB
testcase_11 AC 75 ms
75,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
total = int(input())
A = list(map(int,input().split()))

inf = 1<<60
dp = [inf]*(total+1)
dp[0] = 0
for a in A:
    ndp = [inf]*(total+1)
    for j in range(total+1):
        if dp[j] == inf:
            continue
        if a+j <= total:
            ndp[a+j] = min(ndp[a+j],dp[j]<<1)
        if a*j <= total:
            ndp[a*j] = min(ndp[a*j],1+dp[j]<<1)
    dp = ndp

ans = []

for i in range(1,n)[::-1]:
    if dp[total] >> i & 1:
        ans.append("*")
    else:
        ans.append("+")
print(*ans,sep="")
0