{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\u003cp\u003eBessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 1,000,000) hours (conveniently labeled 0..\u003ci\u003eN\u003c/i\u003e-1) so that she produces as much milk as possible.\u003c/p\u003e\u003cp\u003eFarmer John has a list of \u003ci\u003eM\u003c/i\u003e (1 ≤\u003ci\u003e M\u003c/i\u003e ≤ 1,000) possibly overlapping intervals in which he is available for milking. Each interval \u003ci\u003ei\u003c/i\u003e has a starting hour (0 ≤ \u003ci\u003estarting_hour\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e), an ending hour (\u003ci\u003estarting_hour\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u0026lt; \u003ci\u003eending_hour\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e), and a corresponding efficiency (1 ≤ \u003ci\u003eefficiency\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 1,000,000) which indicates how many gallons of milk that he can get out of Bessie in that interval. Farmer John starts and stops milking at the beginning of the starting hour and ending hour, respectively. When being milked, Bessie must be milked through an entire interval.\u003c/p\u003e\u003cp\u003eEven Bessie has her limitations, though. After being milked during any interval, she must rest \u003ci\u003eR\u003c/i\u003e (1 ≤ \u003ci\u003eR\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e) hours before she can start milking again. Given Farmer Johns list of intervals, determine the maximum amount of milk that Bessie can produce in the \u003ci\u003eN\u003c/i\u003e hours.\u003c/p\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e* Line 1: Three space-separated integers: \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e, and \u003ci\u003eR\u003c/i\u003e\u003cbr\u003e* Lines 2..\u003ci\u003eM\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+1 describes FJ\u0027s ith milking interval withthree space-separated integers: \u003ci\u003estarting_hour\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e , \u003ci\u003eending_hour\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e , and \u003ci\u003eefficiency\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e* Line 1: The maximum number of gallons of milk that Bessie can product in the \u003ci\u003eN\u003c/i\u003e hours\u003c/p\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 4 2\r\n1 2 8\r\n10 12 19\r\n3 6 24\r\n7 10 31\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e43\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}