Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The world famous online bookstore SiruSeri.Com has announced an awards scheme for its
- customers. As an inaugural offer, every customer who has bought a book during the past
- year will receive a gift coupon that can be used to order books free from the bookstore.
- Each coupon has a fixed value. The catch is that the coupon must be used to buy three
- different books, such that the total value of the books exactly adds up to the value of the
- coupon.
- For instance, suppose that the coupon has value 600 and the books available in the
- catalogue cost 136, 411, 211, 200, 275, 189, 232 and 375. Then, one possible way to use the
- coupon is to order the books costing 136, 275 and 189, which add up to 600, the value of
- the coupon. The coupon cannot be used to order three copies of the book costing 200 or
- one copy of the book costing 136 and two copies of the book costing 232, though both these
- orders add up to 600, because the coupon must be used to buy three different books. The
- books costing 189 and 411 add up to 600, but this is not a valid order because it consists of
- only two books.
- You will be given the value of the gift coupon and the costs of all books available in the
- catalogue of SiruSeri.Com. Your task is to assemble an order consisting of three different
- books whose total value matches that of the coupon. If there is more than one possible
- order, it suffices to report any one.
- Input format
- The first line consists of two integers N and M, where N is the total number of books
- available in the catalogue of SiruSeri.Com and M is the value of the gift coupon. This is
- followed by N lines of input, lines 2,3,. . . ,N+1, each consisting of a single integer giving the
- value of one book in the catalogue.
- Output format
- Your output should consist of three lines, each containing one integer, representing the costs
- of three different books that make up a valid order with total valueM. The costs of the three
- books should be listed in ascending order. If more than one solution is possible, it suffices
- to report any one. If no solution is possible, your output should consist of the number 0 on
- each of the three lines.
- Test data
- You may assume that 3 N 8000. In 30% of the inputs, 3 N 300.
- The value of the gift coupon M is a positive integer. The cost of each book is a positive
- integer. No two books have the same cost.
- 1
- Example
- Here is the sample input and output corresponding to the example discussed above.
- Sample input
- 8 600
- 136
- 411
- 211
- 200
- 275
- 189
- 232
- 375
- Sample output
- 136
- 189
- 275
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement