結果

問題 No.10 +か×か
ユーザー titiatitia
提出日時 2021-11-02 01:24:39
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 478 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 163,208 KB
最終ジャッジ日時 2023-08-01 04:05:39
合計ジャッジ時間 7,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
163,208 KB
testcase_01 AC 80 ms
71,480 KB
testcase_02 AC 76 ms
71,508 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