結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
nsd_fb
|
| 提出日時 | 2015-02-19 06:31:49 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 920 ms / 5,000 ms |
| コード長 | 788 bytes |
| 記録 | |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 77,524 KB |
| 実行使用メモリ | 308,428 KB |
| 最終ジャッジ日時 | 2025-12-06 14:30:06 |
| 合計ジャッジ時間 | 3,775 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 |
ソースコード
n = input()
total = input()
a = map(int, raw_input().split())
dic = {a[0]:''}
for value in a[1:]:
next_dic = {}
for key, operators in dic.iteritems():
next_key = key + value
if next_key <= total:
next_operators = operators + '+'
if next_key in next_dic:
next_dic[next_key] = max(next_dic[next_key], next_operators)
else:
next_dic[next_key] = next_operators
next_key = key * value
if next_key <= total:
next_operators = operators + '*'
if next_key in next_dic:
next_dic[next_key] = max(next_dic[next_key], next_operators)
else:
next_dic[next_key] = next_operators
dic = next_dic
print dic[total]
nsd_fb