結果

問題 No.10 +か×か
ユーザー Navier_Boltzmann
提出日時 2023-06-07 21:28:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 107,252 KB
最終ジャッジ日時 2024-12-30 03:22:34
合計ジャッジ時間 2,677 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N  = int(input())
T = int(input())
A = list(map(int,input().split()))

dp = [[False]*(T+2) for _ in range(N)]
a = A[0]
dp[0][a]=3
for i in range(N-1):
    a = A[i+1]
    
    for j in range(T+1):
        
        if not dp[i][j]:
            continue
        
        dp[i+1][min(j+a,T+1)] = 1
        
    for j in range(T+1):
        
        if not dp[i][j]:
            continue
        if dp[i+1][min(j*a,T+1)]:
            continue
        dp[i+1][min(j*a,T+1)] = 2

ans = []
now = T
for i in range(N-1,0,-1):
    
    a = A[i]
    
    if dp[i][now]==1:
        ans.append('+')
        now -= a
    else:
        ans.append('*')
        now //= a
ans.reverse()
print(*ans,sep='')
    
    
0