{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ca href\u003d\"http://uva.onlinejudge.org/external/115/11559.pdf\" rel\u003d\"nofollow\"\u003e\u003c/a\u003eEvent Planning\n\u003cbr /\u003e\n\u003cb\u003e\u0026nbsp;\u003ca rel\u003d\"nofollow\"\u003e Event Planning\u003c/a\u003e\u0026nbsp;\u003c/b\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e As you didn\u0027t show up to the yearly general meeting of the Nordic Club of Pin Collectors, you were unanimously elected to organize this years excursion to Pin City. You are free to choose from a number of weekends this autumn, and have to find a suitable hotel to stay at, preferably as cheap as possible. \u003c/p\u003e\n\u003cp\u003e You have some constraints: The total cost of the trip must be within budget, of course. All participants must stay at the same hotel, to avoid last years catastrophe, where some members got lost in the city, never being seen again. \u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003ca rel\u003d\"nofollow\"\u003e Input\u003c/a\u003e\u0026nbsp; The input file contains several test cases, each of them as described below. \n\u003cp\u003e The first line of input consists of four integers: 1 \u003ci\u003eN\u003c/i\u003e 200 , the number of participants, 1 \u003ci\u003eB\u003c/i\u003e 500000 , the budget, 1 \u003ci\u003eH\u003c/i\u003e 18 , the number of hotels to consider, and 1 \u003ci\u003eW\u003c/i\u003e 13 , the number of weeks you can choose between. Then follow two lines for each of the \u003ci\u003eH\u003c/i\u003e hotels. The first gives 1 \u003ci\u003ep\u003c/i\u003e 10000 , the price for one person staying the weekend at the hotel. The second contains \u003ci\u003eW\u003c/i\u003e integers, 0 \u003ci\u003ea\u003c/i\u003e 1000 , giving the number of available beds for each weekend at the hotel. \u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003ca rel\u003d\"nofollow\"\u003e Output\u003c/a\u003e\u0026nbsp;\n\u003cp\u003e For each test case, write to the output the minimum cost of the stay for your group, or ``stay home\u0027\u0027 if nothing can be found within the budget, on a line by itself. \u003c/p\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003ca rel\u003d\"nofollow\"\u003e Sample Input\u003c/a\u003e\u0026nbsp;\n\u003cpre\u003e\r\n3 1000 2 3\r\n200\r\n0 2 2\r\n300\r\n27 3 20\r\n5 2000 2 4\r\n300\r\n4 3 0 4\r\n450\r\n7 8 0 13\r\n\u003c/pre\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003ca rel\u003d\"nofollow\"\u003e Sample Output\u003c/a\u003e\u0026nbsp;\n\u003cp\u003e\u003c/p\u003e\n\u003cpre\u003e\r\n900\r\nstay home\r\n\u003c/pre\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003cp\u003e\u003cbr /\u003e\u003c/p\u003e"}}]}