結果
問題 | No.15 カタログショッピング |
ユーザー | nsd_fb |
提出日時 | 2015-02-20 09:49:13 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 482 ms |
コンパイル使用メモリ | 77,552 KB |
実行使用メモリ | 99,800 KB |
最終ジャッジ日時 | 2023-09-06 02:27:23 |
合計ジャッジ時間 | 12,290 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
76,668 KB |
testcase_01 | AC | 75 ms
76,016 KB |
testcase_02 | AC | 75 ms
76,224 KB |
testcase_03 | AC | 115 ms
78,776 KB |
testcase_04 | AC | 75 ms
76,448 KB |
testcase_05 | AC | 4,144 ms
98,584 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
ソースコード
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, [])