結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2015-06-20 01:47:28 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 708 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-07 04:34:59 |
| 合計ジャッジ時間 | 6,833 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 TLE * 1 -- * 7 |
ソースコード
def solve(total, a):
stack = [(total, len(a) - 1, [])]
ans = []
while stack:
t, i, h = stack.pop()
if i == 0:
if t == a[0]:
ans.append(h)
else:
if t % a[i] == 0:
h2 = list(h)
h2.append('*')
stack.append((t // a[i], i - 1, h2))
if t > a[i]:
h2 = list(h)
h2.append('+')
stack.append((t - a[i], i - 1, h2))
ans.sort()
return ''.join(ans[-1][::-1])
def main():
n = int(input())
total = int(input())
a = list(map(int, input().split()))
print(solve(total, a))
if __name__ == '__main__':
main()
しらっ亭