結果

問題 No.10 +か×か
ユーザー pessimist
提出日時 2025-06-08 19:18:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 1,151 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2025-06-08 19:18:25
合計ジャッジ時間 2,062 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read

N,T,*A=map(int,read().split())
dp=[set() for _ in range(N+1)]
dp[N].add(T)
for n in range(N,0,-1):
    x=A[n-1]
    for y in dp[n]:
        if y-x>=0: dp[n-1].add(y-x)
        if y%x==0: dp[n-1].add(y//x)

assert 0 in dp[0]
ans=[]
x=0
for n in range(1,N+1):
    y=A[n-1]
    if x+y in dp[n]:
        ans.append('+')
        x+=y
    else:
        ans.append('*')
        x *= y
print(''.join(ans[1:]))
0