Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
Since arriving on Earth, the Borgor aliens have only eaten burgers. Chef Borgort makes exactly one burger per hour and works for H hours a day. Shipments of ingredients arrive each hour with specific calorie values, and each shipment lasts exactly K hours before expiring. At each hour, Chef Borgort can choose which available (non-expired) shipment to use to maximize the total calories cooked in one day. Input format: First line: Three integers H, S, K Next S lines: Two integers t, c— hour of arrival and calories Constraints: 1 ≤ H ≤ 24, 1 ≤ S ≤ 1000, 1 ≤ K ≤ H Output format: One integer: maximum total calories Sample Input: 5 8 1 1 300 1 500 2 400 2 100 3 200 3 350 4 600 5 250 Sample Output: 2100 Question Input: 10 20 3 1 400 1 300 2 500 2, 45 3 600 3 550 4 350 4 400 5 700 5 650 6 300 6 450 7 550 7 500 8 650 8 600 9 400 9 500 10 550 10 500