結果
問題 | No.15 カタログショッピング |
ユーザー |
![]() |
提出日時 | 2015-02-20 09:49:13 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 1,250 ms |
コンパイル使用メモリ | 77,076 KB |
実行使用メモリ | 105,100 KB |
最終ジャッジ日時 | 2024-06-23 21:22:42 |
合計ジャッジ時間 | 8,333 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 TLE * 1 -- * 3 |
ソースコード
def dfs(index, money, goods): if money == S: print ' '.join(map(str, goods)) return if index == N: return next_money = money + P[index] if next_money <= S: goods.append(index + 1) dfs(index + 1, next_money, goods) goods.pop() if money + accumulation[index] >= S: dfs(index + 1, money, goods) to_int = lambda x: int(x, 10) N, S = map(to_int, raw_input().split()) P = [to_int(raw_input()) for i in xrange(N)] accumulation = [0] * N for i in xrange(N - 2, -1, -1): accumulation[i] = accumulation[i + 1] + P[i + 1] dfs(0, 0, [])