結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-10-11 06:39:57
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 631 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 6,648 KB
実行使用メモリ 47,540 KB
最終ジャッジ日時 2023-09-28 11:39:10
合計ジャッジ時間 9,536 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
7,844 KB
testcase_01 AC 25 ms
7,848 KB
testcase_02 RE -
testcase_03 AC 2,036 ms
47,504 KB
testcase_04 AC 1,622 ms
33,940 KB
testcase_05 RE -
testcase_06 AC 2,023 ms
47,540 KB
testcase_07 RE -
testcase_08 AC 405 ms
15,416 KB
testcase_09 AC 721 ms
21,884 KB
testcase_10 AC 33 ms
7,896 KB
testcase_11 AC 25 ms
7,840 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 + 1) 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