結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-10-11 05:54:42
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 637 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 78,032 KB
実行使用メモリ 292,092 KB
最終ジャッジ日時 2023-08-21 06:14:32
合計ジャッジ時間 5,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
92,604 KB
testcase_01 AC 157 ms
92,784 KB
testcase_02 AC 155 ms
92,568 KB
testcase_03 AC 637 ms
291,228 KB
testcase_04 AC 369 ms
120,044 KB
testcase_05 AC 153 ms
92,580 KB
testcase_06 AC 637 ms
292,092 KB
testcase_07 AC 424 ms
162,504 KB
testcase_08 AC 232 ms
103,144 KB
testcase_09 AC 273 ms
109,636 KB
testcase_10 AC 166 ms
92,952 KB
testcase_11 AC 165 ms
92,628 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 = [["c"] * (T + 1) for i in xrange(N)]
dp[0][A[0]] = ""

for i in xrange(1, N):
    for j in xrange(T + 1):
        if j + A[i] <= T:
            dp[i][j + A[i]] = min(dp[i][j + A[i]], dp[i - 1][j] + "a")
        if j * A[i] <= T:
            dp[i][j * A[i]] = min(dp[i][j * A[i]], dp[i - 1][j] + "b")

print dp[N - 1][T].replace("a", "+").replace("b", "*")
0