Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Cow Roller Coaster
Description The cows are building a roller coaster! They want your help to design as fun a roller coaster as possible, while keeping to the budget. The roller coaster will be built on a long linear stretch of land of length W ≤ _{i}L). Due to varying terrain, each component i can be only built starting at location X (0 ≤ _{i}X ≤ _{i}L - W). The cows want to string together various roller coaster components starting at 0 and ending at _{i}L so that the end of each component (except the last) is the start of the next component.Each component F ≤ 1,000,000) and a cost _{i}C (1 ≤ _{i}C ≤ 1000). The total fun of the roller coster is the sum of the fun from each component used; the total cost is likewise the sum of the costs of each component used. The cows' total budget is _{i}B (1 ≤ B ≤ 1000). Help the cows determine the most fun roller coaster that they can build with their budget.Input Line 1: Three space-separated integers: L, N and B.
Lines 2.. N+1: Line i+1 contains four space-separated integers, respectively: X, _{i}W, _{i}F, and _{i}C._{i}Output Line 1: A single integer that is the maximum fun value that a roller-coaster can have while staying within the budget and meeting all the other constraints. If it is not possible to build a roller-coaster within budget, output -1. Sample Input 5 6 10 0 2 20 6 2 3 5 6 0 1 2 1 1 1 1 3 1 2 5 4 3 2 10 2 Sample Output 17 Hint Taking the 3rd, 5th and 6th components gives a connected roller-coaster with fun value 17 and cost 7. Taking the first two components would give a more fun roller-coaster (25) but would be over budget. Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator