結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
73,056 KB
testcase_01 AC 103 ms
73,140 KB
testcase_02 AC 108 ms
72,988 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 106 ms
72,832 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 166 ms
93,452 KB
testcase_10 AC 114 ms
77,452 KB
testcase_11 AC 110 ms
77,236 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)]==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