結果
問題 |
No.10 +か×か
|
ユーザー |
![]() |
提出日時 | 2018-03-01 00:16:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 676 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 606,964 KB |
最終ジャッジ日時 | 2024-12-23 02:38:25 |
合計ジャッジ時間 | 14,675 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 TLE * 2 MLE * 2 |
ソースコード
import collections def dfs(memo, a, j, s, t, res): if j == len(a) - 1: if s == t: return True else: return False if s in memo[j]: return False memo[j].add(s) if dfs(memo, a, j + 1, s + a[j + 1], t, res): res.append('+') return True if dfs(memo, a, j + 1, s * a[j + 1], t, res): res.append('*') return True else: return False n = int(input()) t = int(input()) a = [int(x) for x in input().split()] memo = [] for i in range(n): memo.append(set()) res = [] dfs(memo, a, 0, a[0], t, res) res.reverse() print(''.join(res))