結果

問題 No.10 +か×か
コンテスト
ユーザー zimpha
提出日時 2017-12-07 02:26:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 118 ms / 5,000 ms
+ 755µs
コード長 533 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 448 ms
コンパイル使用メモリ 96,364 KB
実行使用メモリ 123,392 KB
最終ジャッジ日時 2026-07-19 00:14:43
合計ジャッジ時間 2,717 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
m = int(input())
a = list(map(int, input().split()))
inf = 1 << 60

f = [inf] * (m + 1)
f[0] = 0
for i, x in enumerate(a):
    g = [inf] * (m + 1)
    for j in range(m + 1):
        if f[j] == inf: continue
        if j + x <= m:
            g[j + x] = min(g[j + x], f[j])
        if j * x <= m:
            g[j * x] = min(g[j * x], f[j] | (1 << (n - i)))
    f = g
mask = f[m]
res = []
for i in range(n - 1, 0, -1):
    if mask >> i & 1:
        res.append('*')
    else:
        res.append('+')
print(''.join(res))
0