結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-12 22:16:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 144 ms / 5,000 ms |
| コード長 | 528 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 104,068 KB |
| 最終ジャッジ日時 | 2024-12-14 15:48:12 |
| 合計ジャッジ時間 | 1,697 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
n = int(input())
total = int(input())
A = list(map(int,input().split()))
inf = 1<<60
dp = [inf]*(total+1)
dp[0] = 0
for a in A:
ndp = [inf]*(total+1)
for j in range(total+1):
if dp[j] == inf:
continue
if a+j <= total:
ndp[a+j] = min(ndp[a+j],dp[j]<<1)
if a*j <= total:
ndp[a*j] = min(ndp[a*j],1+dp[j]<<1)
dp = ndp
ans = []
for i in range(1,n)[::-1]:
if dp[total] >> i & 1:
ans.append("*")
else:
ans.append("+")
print(*ans,sep="")