結果

問題 No.10 +か×か
ユーザー 👑 colognecologne
提出日時 2022-01-20 17:00:03
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 940 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 146,660 KB
最終ジャッジ日時 2023-08-15 15:20:14
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,128 KB
testcase_01 AC 72 ms
71,056 KB
testcase_02 AC 73 ms
71,244 KB
testcase_03 RE -
testcase_04 AC 146 ms
101,460 KB
testcase_05 AC 74 ms
71,168 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 76 ms
75,228 KB
testcase_11 AC 76 ms
74,844 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