結果
問題 | No.15 カタログショッピング |
ユーザー | Tawara |
提出日時 | 2015-12-20 01:31:53 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 430 bytes |
コンパイル時間 | 2,662 ms |
コンパイル使用メモリ | 77,144 KB |
実行使用メモリ | 462,360 KB |
最終ジャッジ日時 | 2023-10-17 13:10:27 |
合計ジャッジ時間 | 10,085 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,932 KB |
testcase_01 | AC | 73 ms
75,932 KB |
testcase_02 | AC | 96 ms
78,668 KB |
testcase_03 | AC | 97 ms
78,708 KB |
testcase_04 | AC | 75 ms
76,064 KB |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
ソースコード
N,S=map(int,raw_input().split()) P=[input() for i in xrange(N)] dp = {0:0} ans = [] while dp: tmp_dp = {} for k,v in dp.iteritems(): for j in xrange(N): jbit = 1<<j nk = k+jbit if k&jbit != 0 or nk in tmp_dp:continue nv = v+P[j] if nv < S: tmp_dp[nk] = nv elif nv == S: ans.append(nk) dp = tmp_dp ans = [" ".join(str(i+1) for i in xrange(N) if (1<<i)&s) for s in set(ans)] for a in sorted(set(ans)): print a