結果

問題 No.10 +か×か
ユーザー nebukuro09nebukuro09
提出日時 2016-10-06 11:03:27
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 541 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 6,508 KB
実行使用メモリ 10,440 KB
最終ジャッジ日時 2023-08-13 23:58:10
合計ジャッジ時間 7,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,440 KB
testcase_01 AC 11 ms
6,156 KB
testcase_02 WA -
testcase_03 AC 462 ms
6,048 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
total = input()
A = map(int, raw_input().split())

limits = [0 for _ in xrange(N)]
limits[N-1] = total-A[N-1]
for i in xrange(N-2, -1, -1):
    limits[i] = limits[i+1]-A[i]

mem = {}
def rec(p, acm, ops):
    if p >= N:
        return ops if acm == total else False
    if acm > limits[p]:
        return False
    a = rec(p+1, acm+A[p], ops+'+')
    if a:
        mem[(p, acm)] = a
        return a
    a = rec(p+1, acm*A[p], ops+'*')
    if a:
        mem[(p, acm)] = a
        return a
    return False
print rec(1, A[0], '')
0