結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-16 01:16:32 |
| 言語 | Python2 (2.7.18) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 493 bytes |
| コンパイル時間 | 258 ms |
| コンパイル使用メモリ | 7,072 KB |
| 実行使用メモリ | 815,324 KB |
| 最終ジャッジ日時 | 2024-07-04 14:47:26 |
| 合計ジャッジ時間 | 5,510 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 1 MLE * 1 -- * 8 |
ソースコード
from collections import defaultdict
N = int(raw_input())
T = int(raw_input())
a = map(int, raw_input().split())
dp = set([a[0]])
s2e = defaultdict(lambda :"1"*51)
s2e[a[0]] = ""
for ai in a[1:]:
ndp = set([])
for s in dp:
if s+ai <= T:
ndp.add(s+ai)
s2e[s+ai] = min(s2e[s+ai], s2e[s]+"0")
if s*ai <= T:
ndp.add(s*ai)
s2e[s*ai] = min(s2e[s*ai], s2e[s]+"1")
dp = ndp
print s2e[T].replace("1","*").replace("0","+")