結果

問題 No.10 +か×か
ユーザー tktk_snsntktk_snsn
提出日時 2021-10-26 23:20:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-15 23:12:06
合計ジャッジ時間 6,785 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
T = int(input())
A = list(map(int, input().split()))
ans = []
tmp = []


def dfs(i, val):
    if i == N:
        if val == T:
            ans.append("".join(tmp))
        return

    if val + A[i] <= T:
        tmp.append("0")
        dfs(i + 1, val + A[i])
        tmp.pop()
    if val * A[i] <= T:
        tmp.append("1")
        dfs(i + 1, val * A[i])
        tmp.pop()


dfs(1, A[0])
answer = sorted(ans)[0]
print(answer.replace("0", "+").replace("1", "*"))
0