Story of Seasons
메모리 제한1024 MB
매일 최대 X개의 씨앗을 심을 수 있고, 겨울 전 L일이 남았을 때 심은 씨앗은 L일이 지나면 V의 이익을 낸다. 총이익의 최댓값을 구한다.
문제
You are a super farmer with some vegetable seeds and an infinitely large farm. In fact, not only are you a farmer, but you are also secretly a super programmer! As a super programmer, you hope to maximize the profit of your farming using your programming skills.
Since your daily energy is limited, you can plant at most seeds each day. In the beginning, you have kinds of vegetable seeds. The number of seeds of the -th kind of vegetable is , and each seed of this kind needs days to mature from the day it is planted. Once it matures, you can sell it for dollars. Assume that no energy or time is required for harvesting and selling vegetables. Also, your farm is infinitely large so the growing vegetables do not crowd out each other.
Notice that although the area of your farm is infinite, the number of days that you can plant seeds is limited. The warm season only lasts days, and after that, the harsh winter comes. Any vegetable that has not matured yet will die immediately and cannot be turned into profit. The remaining seeds that were not planted cannot be turned into profit either.
As a super farmer and a super programmer, you want to come up with a perfect planting plan that will maximize your profit. Find the total amount of profit you will earn.
입력
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains three integers , , and : the number of days of the warm season, the number of kinds of vegetable seeds you have to start with, and the maximum number of seeds you can plant each day, respectively.
The next lines describe the seeds. The -th line contains three integers , , and : the quantity of this kind of seed, the number of days it needs to mature, and the value of each matured plant, respectively.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the maximum amount of money you can earn by optimizing your farming plan.
제한
- .
- , for all .
- , for all .