結果
問題 | No.15 カタログショッピング |
ユーザー | roiti46 |
提出日時 | 2015-10-11 06:55:41 |
言語 | PyPy2 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 77,928 KB |
実行使用メモリ | 101,108 KB |
最終ジャッジ日時 | 2023-09-28 11:39:30 |
合計ジャッジ時間 | 3,722 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 166 ms
92,340 KB |
testcase_01 | AC | 163 ms
92,372 KB |
testcase_02 | AC | 168 ms
92,492 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
ソースコード
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll N, S = map(int, raw_input().split()) P = [int(raw_input()) for i in xrange(N)] dic = {0:()} for i in xrange(1, N / 2 + 1): for select in it.combinations(range(N / 2), i): s = sum(P[j] for j in select) if s in dic: dic[s] = min(dic[s], select) else: dic[s] = select ans = [32] for i in xrange(1, N - N / 2 + 1): for select in it.combinations(range(N / 2, N), i): s = sum(P[j] for j in select) if S - s in dic: ans = min(ans, list(dic[S - s] + select)) ans = [i + 1 for i in ans] print " ".join(map(str, ans))