Codeforces Round 213 (Div. 2)
D
Free Market
Codeforces
未评级
原题
← CE →
翻译中…

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.

翻译中…

Input

翻译中…

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}$).

翻译中…

Output

翻译中…

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.

翻译中…

Note

翻译中…

In the first sample John can act like this:

翻译中…
  • Take the first item ($1 - 0 ≤ 2$).
  • Exchange the first item for the second one ($3 - 1 ≤ 2$).
  • Take the first item ($1 - 0 ≤ 2$).
翻译中…

样例

Input #1
3 2
1 3 10
Output #1
4 3
InputCopy OutputCopy
Input #2
3 5
1 2 3
Output #2
6 2
InputCopy OutputCopy
Input #3
10 10000
10000 9999 1 10000 10000 10000 1 2 3 4
Output #3
50010 6
InputCopy OutputCopy
题目信息
题号
365D
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。