結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-10-11 06:41:35
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,030 ms / 5,000 ms
コード長 632 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 6,464 KB
実行使用メモリ 47,584 KB
最終ジャッジ日時 2023-08-21 06:15:29
合計ジャッジ時間 9,655 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
7,716 KB
testcase_01 AC 23 ms
7,796 KB
testcase_02 AC 24 ms
7,756 KB
testcase_03 AC 2,030 ms
47,584 KB
testcase_04 AC 1,606 ms
33,892 KB
testcase_05 AC 23 ms
7,796 KB
testcase_06 AC 2,020 ms
47,580 KB
testcase_07 AC 1,610 ms
33,792 KB
testcase_08 AC 407 ms
15,388 KB
testcase_09 AC 733 ms
21,916 KB
testcase_10 AC 32 ms
8,004 KB
testcase_11 AC 25 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
T = int(raw_input())
A = map(int, raw_input().split())
dp = [[False] * (T + 10) for i in xrange(N + 1)]
dp[N][T] = True

for i in xrange(N - 1, -1, -1):
    for j in xrange(T + 1):
        if j + A[i] <= T and dp[i + 1][j + A[i]]:
            dp[i][j] = True
        if j * A[i] <= T and dp[i + 1][j * A[i]]:
            dp[i][j] = True

ans = "";
c = A[0];
for i in xrange(1, N):
    if dp[i + 1][c + A[i]]:
        ans += "+"
        c += A[i]
    else:
        ans += "*"
        c *= A[i]
print ans
0