| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 서브태스크 참고 (추가 시간 없음) | 1024 MB | 21 | 7 | 7 | 33.333% |
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 $\mathbf{X}$ seeds each day. In the beginning, you have $\mathbf{N}$ kinds of vegetable seeds. The number of seeds of the $i$-th kind of vegetable is $\mathbf{Q_i}$, and each seed of this kind needs $\mathbf{L_i}$ days to mature from the day it is planted. Once it matures, you can sell it for $\mathbf{V_i}$ 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 $\mathbf{D}$ 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, $\mathbf{T}$. $\mathbf{T}$ test cases follow.
The first line of each test case contains three integers $\mathbf{D}$, $\mathbf{N}$, and $\mathbf{X}$: 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 $\mathbf{N}$ lines describe the seeds. The $i$-th line contains three integers $\mathbf{Q_i}$, $\mathbf{L_i}$, and $\mathbf{V_i}$: 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 $x$ is the test case number (starting from 1) and $y$ is the maximum amount of money you can earn by optimizing your farming plan.
시간 제한: 20 초
시간 제한: 60 초
시간 제한: 60 초
2 5 4 1 1 2 3 1 3 10 1 4 5 1 2 2 5 1 1 1 1 1
Case #1: 18 Case #2: 1
In Sample Case #1, there are $\mathbf{D} = 5$ days, $\mathbf{N} = 4$ kinds of vegetables and you can plant at most $\mathbf{X} = 1$ seed each day. Supposing the $4$ kinds of vegetables are spinach, pumpkin, carrot and cabbage, we have that
The maximum profit you can make is $18$ dollars. One of the schedules you can use is:
And with this schedule, the vegetables will mature and turn into profit as following days:
Note that the cabbage is supposed to mature on day $6$, but it will actually die because of the winter.
1 5 3 4 5 2 3 2 3 10 2 4 5
Case #1: 45
In Additional Sample Case #1, there are $\mathbf{D} = 5$ days, $\mathbf{N} = 3$ kinds of vegetables and you can plant at most $\mathbf{X} = 4$ seeds each day. Supposing the $3$ kinds of vegetables are spinach, pumpkin and carrot, we have that
The maximum profit you can make is $45$ dollars. One of the schedules you can use is:
And with this schedule, the vegetables will mature and turn into profit as following days:
Contest > Google > Kick Start > Google Kick Start 2022 > Round F C번