結果
| 問題 |
No.15 カタログショッピング
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-11 06:55:41 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 703 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 76,956 KB |
| 実行使用メモリ | 98,316 KB |
| 最終ジャッジ日時 | 2024-07-21 06:19:21 |
| 合計ジャッジ時間 | 3,010 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 7 |
ソースコード
# -*- 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))