結果

問題 No.10 +か×か
コンテスト
ユーザー convexineq
提出日時 2020-12-06 21:24:19
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 424 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 178 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 103,956 KB
最終ジャッジ日時 2025-12-06 14:57:49
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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