結果

問題 No.10 +か×か
コンテスト
ユーザー aaaaaaaaaa2230
提出日時 2021-04-12 22:16:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 113 ms / 5,000 ms
+ 947µs
コード長 528 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 123,136 KB
最終ジャッジ日時 2026-07-19 02:50:53
合計ジャッジ時間 2,374 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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