Submit | All submissions | Best solutions | Back to list |
EIUGIFTS - Women day |
Women's day is coming soon, Beo wants to buy gifts for his mother and his sister. Beo want to buy two gifts with similar prices but he has only K VND. He went to the XYZ store,where there were N items.
Help Beo to choose gifts so that the total price is largest but does not exceed the amount of Beo has, and the difference between the two gifts is the smallest.
Input
The first line contains an integer N and K. N is the number of items in the store and K is the amount of money Beo has
The ith line of the next N lines contains an integer which are price of the items
(0<N<=10^5,1<= K<=10^9, 0<ai<=10^5)
Output
Output the total amount of money to be spent and the difference between the two gifts (non-negative). If it is not able to select gifts, output "-1 -1".
Example
Input:5 100
10
50
60
40
50
Output:100 0
Added by: | Ha Minh Ngoc |
Date: | 2015-01-13 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NCSHARP GOSU JULIA PYPY3 |