結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-10-11 06:41:35
言語 Python2
(2.7.18)
結果
AC  
実行時間 2,162 ms / 5,000 ms
コード長 632 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 48,128 KB
最終ジャッジ日時 2024-05-08 11:48:38
合計ジャッジ時間 10,197 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,320 KB
testcase_01 AC 19 ms
8,320 KB
testcase_02 AC 20 ms
8,320 KB
testcase_03 AC 2,089 ms
48,128 KB
testcase_04 AC 1,677 ms
34,560 KB
testcase_05 AC 22 ms
8,192 KB
testcase_06 AC 2,162 ms
48,000 KB
testcase_07 AC 1,635 ms
34,560 KB
testcase_08 AC 411 ms
15,872 KB
testcase_09 AC 738 ms
22,656 KB
testcase_10 AC 31 ms
8,192 KB
testcase_11 AC 23 ms
8,320 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