結果

問題 No.15 カタログショッピング
コンテスト
ユーザー nsd_fb
提出日時 2015-02-20 09:35:56
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 527 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 328 ms
コンパイル使用メモリ 77,584 KB
最終ジャッジ日時 2025-12-03 14:03:48
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def dfs(index, money, goods):
    if money == S:
        print ' '.join(goods)
        return

    if index == N or money > S or money + accumulation[index] < S:
        return

    goods.append(str(index + 1))
    dfs(index + 1, money + P[index], goods)
    goods.pop()
    dfs(index + 1, money, goods)


N, S = map(int, raw_input().split())
P = [input() for i in xrange(N)]

accumulation = [0] * N
accumulation[N - 1] = P[N - 1]
for i in xrange(N - 2, -1, -1):
    accumulation[i] = accumulation[i + 1] + P[i]

dfs(0, 0, [])
0