結果
問題 | No.10 +か×か |
ユーザー | kutsutama |
提出日時 | 2018-03-01 00:24:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 538 ms / 5,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 82 ms |
コンパイル使用メモリ | 10,928 KB |
実行使用メモリ | 84,560 KB |
最終ジャッジ日時 | 2023-08-21 06:24:23 |
合計ジャッジ時間 | 2,108 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
8,568 KB |
testcase_01 | AC | 18 ms
8,488 KB |
testcase_02 | AC | 19 ms
8,532 KB |
testcase_03 | AC | 308 ms
51,460 KB |
testcase_04 | AC | 24 ms
9,276 KB |
testcase_05 | AC | 19 ms
8,508 KB |
testcase_06 | AC | 538 ms
84,560 KB |
testcase_07 | AC | 174 ms
34,136 KB |
testcase_08 | AC | 37 ms
12,096 KB |
testcase_09 | AC | 50 ms
15,620 KB |
testcase_10 | AC | 18 ms
8,564 KB |
testcase_11 | AC | 19 ms
8,644 KB |
ソースコード
import collections def dfs(memo, a, j, s, t, res): if s in memo[j]: return False memo[j].add(s) if s > t: return False if j == len(a) - 1: if s == t: return True else: return False 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))