結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-16 01:23:50 |
| 言語 | Python2 (2.7.18) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 551 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 7,068 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-07-04 14:47:31 |
| 合計ジャッジ時間 | 1,054 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 9 |
ソースコード
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:]