301921: CF364B. Free Market
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Free Market
题意翻译
有 $n$ 个品种的物品,每个物品的价格为 $c_i$,每次你可以从你拥有的物品中挑取部分去商店去兑换,也可以什么都不拿。兑换有如下限制: 1. 你拿去兑换的物品(不妨设拿去兑换的物品可空集合为 $S$),都要换成集合 $S$ 所没有的。比如 $(a,b) \to (v,a)$ 就是不合法的。 2. 你拿去兑换的物品集 $S_1$ 里的价值和 $\mathit{cost}_1$ 与你兑换回来的物品集 $S_2$ 里的价值和 $\mathit{cost}_2$ 需要满足:$\mathit{cost}_1 + d \ge \mathit{cost}_2$。 每天只能去兑换一次。 问通过兑换可以获得的物品集的价值和最大值,以及所需的兑换天数。题目描述
John Doe has recently found a "Free Market" in his city — that is the place where you can exchange some of your possessions for other things for free. John knows that his city has $ n $ items in total (each item is unique). You can bring any number of items to the market and exchange them for any other one. Note that each item is one of a kind and that means that you cannot exchange set $ {a,b} $ for set $ {v,a} $ . However, you can always exchange set $ x $ for any set $ y $ , unless there is item $ p $ , such that $ p $ occurs in $ x $ and $ p $ occurs in $ y $ . For each item, John knows its value $ c_{i} $ . John's sense of justice doesn't let him exchange a set of items $ x $ for a set of items $ y $ , if $ s(x)+d<s(y) $ ( $ s(x) $ is the total price of items in the set $ x $ ). During one day John can exchange only one set of items for something else. Initially, he has no items. John wants to get a set of items with the maximum total price. Find the cost of such set and the minimum number of days John can get it in.输入输出格式
输入格式
The first line contains two space-separated integers $ n $ , $ d $ ( $ 1<=n<=50 $ , $ 1<=d<=10^{4} $ ) — the number of items on the market and John's sense of justice value, correspondingly. The second line contains $ n $ space-separated integers $ c_{i} $ ( $ 1<=c_{i}<=10^{4} $ ).
输出格式
Print two space-separated integers: the maximum possible price in the set of items John can get and the minimum number of days needed to get such set.
输入输出样例
输入样例 #1
3 2
1 3 10
输出样例 #1
4 3
输入样例 #2
3 5
1 2 3
输出样例 #2
6 2
输入样例 #3
10 10000
10000 9999 1 10000 10000 10000 1 2 3 4
输出样例 #3
50010 6