結果

問題 No.10 +か×か
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-07 21:28:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 86,544 KB
実行使用メモリ 117,480 KB
最終ジャッジ日時 2023-08-28 18:34:33
合計ジャッジ時間 3,299 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
72,704 KB
testcase_01 AC 100 ms
72,868 KB
testcase_02 AC 99 ms
72,828 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 102 ms
72,976 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 157 ms
91,792 KB
testcase_10 AC 107 ms
77,288 KB
testcase_11 AC 105 ms
77,204 KB
権限があれば一括ダウンロードができます

ソースコード

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