結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2015-10-11 06:41:35 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 2,184 ms / 5,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 48,128 KB |
最終ジャッジ日時 | 2024-12-14 15:32:52 |
合計ジャッジ時間 | 10,200 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
# -*- 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