結果

問題 No.10 +か×か
ユーザー convexineq
提出日時 2020-12-06 21:24:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 424 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,056 KB
実行使用メモリ 102,144 KB
最終ジャッジ日時 2024-12-14 15:46:55
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
t = int(input())
*a, = map(int,input().split())

dp = [-1]*(t+1) # +: 1 *: 0
dp[a[0]] = 0
for ai in a[1:]:
    ndp = [-1]*(t+1)
    for i,xi in enumerate(dp):
        if xi==-1: continue
        if i*ai <= t:
            ndp[i*ai] = max(ndp[i*ai], xi*2)
        if i+ai <= t:
            ndp[i+ai] = max(ndp[i+ai], xi*2+1)
    dp = ndp

print("".join(["+" if dp[t]>>i&1 else "*" for i in range(n-2,-1,-1)]))
0