結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2015-10-11 06:39:57 |
言語 | Python2 (2.7.18) |
結果 |
RE
|
実行時間 | - |
コード長 | 631 bytes |
コンパイル時間 | 65 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 48,128 KB |
最終ジャッジ日時 | 2024-07-21 06:19:04 |
合計ジャッジ時間 | 10,280 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 RE * 3 |
ソースコード
# -*- 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