結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-04-16 01:23:50
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 6,616 KB
実行使用メモリ 7,340 KB
最終ジャッジ日時 2023-09-17 20:40:34
合計ジャッジ時間 1,062 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,308 KB
testcase_01 AC 13 ms
6,196 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 13 ms
6,288 KB
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(raw_input())
T = int(raw_input())
a = map(int, raw_input().split())
dp = set([T])
s2e = defaultdict(lambda :"1"*51)
s2e[T] = ""

for i in xrange(N-1, -1, -1):
    ndp = set([])
    for t in dp:
        if i > 0 and t-a[i] > 0 or i == 0 and t-a[i] == 0:
            ndp.add(t-a[i])
            s2e[t-a[i]] = min(s2e[t-a[i]], "0"+s2e[t])
        if t%a[i] == 0:
            ndp.add(t/a[i])
            s2e[t/a[i]] = min(s2e[t/a[i]], "1"+s2e[t])
    dp = ndp

print s2e[0].replace("1","*").replace("0","+")[1:]
0