結果

問題 No.10 +か×か
ユーザー 👑 colognecologne
提出日時 2022-01-20 17:00:03
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 940 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 138,680 KB
最終ジャッジ日時 2024-05-03 02:38:48
合計ジャッジ時間 1,613 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
54,056 KB
testcase_01 AC 37 ms
54,084 KB
testcase_02 AC 34 ms
52,132 KB
testcase_03 RE -
testcase_04 AC 98 ms
91,880 KB
testcase_05 AC 33 ms
52,708 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 41 ms
57,628 KB
testcase_11 AC 40 ms
58,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def main():
    N = int(input())
    Total = int(input())
    *A, = map(int, input().split())

    DP = [[None]*(Total+1) for i in range(N)]
    DP[0][A[0]] = ''

    for step in range(1, N):
        for i in range(Total+1):
            if DP[step-1][i] is not None:
                if i * A[step] <= Total:
                    if DP[step][i * A[step]] is None:
                        DP[step][i * A[step]] = DP[step-1][i] + '*'
                    else:
                        DP[step][i * A[step]] = max(DP[step][i * A[step]], DP[step-1][i] + '*')
                if i + A[step] <= Total:
                    if DP[step][i + A[step]] is None:
                        DP[step][i + A[step]] = DP[step-1][i] + '+'
                    else:
                        DP[step][i + A[step]] = max(DP[step][i * A[step]], DP[step-1][i] + '+')

    print(DP[-1][-1])

if __name__ == '__main__':
    main()
0