結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 01:24:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 101,512 KB
最終ジャッジ日時 2024-04-19 03:48:11
合計ジャッジ時間 6,744 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,448 KB
testcase_01 AC 38 ms
51,968 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

S=[0,A[0]]
for a in A[1:]:
    S.append(min(S[-1]+a,S[-1]*a))

def calc(i,T):
    #print(i,T)
    if i==0:
        if T==A[0]:
            return ""
        else:
            return -1
        
    if calc(i-1,T-A[i])!=-1:
        return calc(i-1,T-A[i])+"+"

    if T%A[i]==0 and T//A[i]>=S[i]:
        if calc(i-1,T//A[i])!=-1:
            return calc(i-1,T//A[i])+"*"
        
    return -1

print(calc(N-1,T))
0