結果

問題 No.10 +か×か
ユーザー taisuketaisuke
提出日時 2023-02-21 23:36:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 3,409 ms / 5,000 ms
コード長 468 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 298,924 KB
最終ジャッジ日時 2023-09-29 12:50:08
合計ジャッジ時間 10,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,896 KB
testcase_01 AC 13 ms
7,780 KB
testcase_02 AC 12 ms
7,780 KB
testcase_03 AC 3,409 ms
298,924 KB
testcase_04 AC 497 ms
36,880 KB
testcase_05 AC 13 ms
7,784 KB
testcase_06 AC 3,399 ms
297,148 KB
testcase_07 AC 1,442 ms
108,332 KB
testcase_08 AC 271 ms
28,228 KB
testcase_09 AC 341 ms
30,000 KB
testcase_10 AC 16 ms
8,288 KB
testcase_11 AC 13 ms
7,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
t = int(input())
a = list(map(int, input().split()))

dp = [['0' for i in range(t+1)] for j in range(n+1)]
dp[1][a[0]] = '1'

for i in range(1, n):
    for j in range(t+1):
        if dp[i][j] != '0':
            x = j + a[i]
            if x <= t:
                dp[i+1][x] = max(dp[i+1][x], dp[i][j] + '+')
            x = j * a[i]
            if x <= t:
                dp[i+1][x] = max(dp[i+1][x], dp[i][j] + '*')

ans = dp[n][t]
print(ans[1:n])
0