結果

問題 No.10 +か×か
コンテスト
ユーザー DialBird
提出日時 2019-07-27 14:48:25
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
MLE  
実行時間 -
コード長 559 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,179 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 1,311,836 KB
最終ジャッジ日時 2026-03-23 19:21:21
合計ジャッジ時間 4,161 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 MLE * 2 -- * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    """ main """
    N = int(input())
    TOTAL = int(input())
    AS = list(map(int, input().split()))

    # 演算子文字列, result
    q = [('', AS[0])]

    for optstr, total in q:
        if len(optstr) == N-1 and total == TOTAL:
            print(optstr)
            break
        elif len(optstr) == N-1:
            continue

        cur_a = AS[len(optstr)+1]

        if total+cur_a <= TOTAL:
            q.append((optstr + '+', total+cur_a))
        if total*cur_a <= TOTAL:
            q.append((optstr + '*', total*cur_a))

main()
0