結果
| 問題 | 
                            No.15 カタログショッピング
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nsd_fb
                         | 
                    
| 提出日時 | 2015-02-20 09:35:56 | 
| 言語 | Python2  (2.7.18)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 527 bytes | 
| コンパイル時間 | 220 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 13,896 KB | 
| 最終ジャッジ日時 | 2024-06-23 21:22:29 | 
| 合計ジャッジ時間 | 6,721 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 TLE * 1 -- * 4 | 
ソースコード
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, [])
            
            
            
        
            
nsd_fb