Submit | All submissions | Best solutions | Back to list |
EIBIRG - BIRTHDAY GIFT |
Teo wants to buy a gift for his girlfriend on her upcoming birthday. In the gift store, there are N gift items, priced respectively V0, V1, V2, ... ,VN coins, and Teo has K coins. Please write a program to help Teo find a gift worth equal to or close to the amount Teo has.;
Input
+ The first line contains the number of gifts in store: N (0 < N < 105) and the amount of money that Teo has: K (0 < K < 109).
+ The second line contains N positive integers representing the price of each gift (0 < Vi < 109).
+ The first line contains the number of gifts in store: N (0 < N < 105) and the amount of money that Teo has: K (0 < K < 109).
+ The second line contains N positive integers representing the price of each gift (0 < Vi < 109).
Output
Return the value of the item in the store in accordance with the amount of money Teo has.
Example
Input: 6 30 17 55 26 19 25 37 176 Output: 26
Added by: | Ha Minh Ngoc |
Date: | 2020-06-13 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |