{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"The advice to \"buy low\" is half the formula to success in the bovine stock market.To be considered a great investor you must also follow this problems\u0027 advice:\r\u003cbr\u003e\u003cpre\u003e \"Buy low; buy lower\"\u003c/pre\u003e\r\u003cbr\u003eEach time you buy a stock, you must purchase it at a lower price than the previous time you bought it. The more times you buy at a lower price than before, the better! Your goal is to see how many times you can continue purchasing at ever lower prices.\r\u003cbr\u003e\r\u003cbr\u003eYou will be given the daily selling prices of a stock (positive 16-bit integers) over a period of time. You can choose to buy stock on any of the days. Each time you choose to buy, the price must be strictly lower than the previous time you bought stock. Write a program which identifies which days you should buy stock in order to maximize the number of times you buy.\r\u003cbr\u003e\r\u003cbr\u003eHere is a list of stock prices:\r\u003cbr\u003e\u003cpre\u003e Day 1 2 3 4 5 6 7 8 9 10 11 12\r\u003cbr\u003ePrice 68 69 54 64 68 64 70 67 78 62 98 87\u003c/pre\u003e\r\u003cbr\u003e\r\u003cbr\u003eThe best investor (by this problem, anyway) can buy at most four times if each purchase is lower then the previous purchase. One four day sequence (there might be others) of acceptable buys is:\r\u003cbr\u003e\u003cpre\u003eDay 2 5 6 10\r\u003cbr\u003ePrice 69 68 64 62\u003c/pre\u003e"}},{"title":"Input","value":{"format":"HTML","content":"* Line 1: N (1 \u0026lt;\u003d N \u0026lt;\u003d 5000), the number of days for which stock prices are given\r\u003cbr\u003e\r\u003cbr\u003e* Lines 2..etc: A series of N space-separated integers, ten per line except the final line which might have fewer integers.\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"Two integers on a single line:\r\u003cbr\u003e * The length of the longest sequence of decreasing prices\r\u003cbr\u003e * The number of sequences that have this length (guaranteed to fit in 31 bits)\r\u003cbr\u003e\r\u003cbr\u003eIn counting the number of solutions, two potential solutions are considered the same (and would only count as one solution) if they repeat the same string of decreasing prices, that is, if they \"look the same\" when the successive prices are compared. Thus, two different sequence of \"buy\" days could produce the same string of decreasing prices and be counted as only a single solution.\r\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e12\r\n68 69 54 64 68 64 70 67 78 62\r\n98 87\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}