結果

問題 No.10 +か×か
ユーザー HydruHydru
提出日時 2023-01-16 15:30:36
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 514 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 522,544 KB
最終ジャッジ日時 2023-08-29 22:29:15
合計ジャッジ時間 6,716 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,268 KB
testcase_01 AC 68 ms
71,284 KB
testcase_02 AC 70 ms
71,328 KB
testcase_03 MLE -
testcase_04 AC 945 ms
369,728 KB
testcase_05 AC 68 ms
71,476 KB
testcase_06 MLE -
testcase_07 AC 729 ms
369,440 KB
testcase_08 AC 212 ms
147,392 KB
testcase_09 AC 340 ms
224,172 KB
testcase_10 AC 78 ms
75,744 KB
testcase_11 AC 73 ms
75,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
total=int(input())
A=list(map(int,input().split()))

DP=[[[0,0] for _ in range(total+1)] for _ in range(n+1)]

DP[n][total][0]=1

for i in range(n-1,-1,-1):
    for j in range(A[i],total+1):
        if DP[i+1][j][0]==0 and DP[i+1][j][1]==0:
            continue
        if j%A[i]==0:
            DP[i][j//A[i]][1]=1
        DP[i][j-A[i]][0]=1


ans=""
num=A[0]

for i in range(1,n):
    if DP[i][num][0]==1:
        ans+="+"
        num+=A[i]
    else:
        ans+="*"
        num*=A[i]

print(ans)
0