Files
PAT/source/html/t1002.html
T

23 lines
5.8 KiB
HTML

Business
<div class="ques-view"><p>As the manager of your company, you have to carefully consider, for each project, the time taken to finish it, the deadline, and the profit you can gain, in order to decide if your group should take this project. For example, given 3 projects as the following:</p>
<ul>
<li>Project[1] takes 3 days, it must be finished in 3 days in order to gain 6 units of profit.</li>
<li>Project[2] takes 2 days, it must be finished in 2 days in order to gain 3 units of profit.</li>
<li>Project[3] takes 1 day only, it must be finished in 3 days in order to gain 4 units of profit.</li>
</ul>
<p>You may take Project[1] to gain 6 units of profit. But if you take Project[2] first, then you will have 1 day left to complete Project[3] just in time, and hence gain 7 units of profit in total. Notice that once you decide to work on a project, you have to do it from beginning to the end without any interruption.</p>
<h3 id="input-specification-">Input Specification:</h3>
<p>Each input file contains one test case. For each case, the first line gives a positive integer <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> (<span class="katex"><span class="katex-mathml"><math><mrow><mo>≤</mo><mn>5</mn><mn>0</mn></mrow>\le 50</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.64444em;"></span><span class="strut bottom" style="height:0.78041em;vertical-align:-0.13597em;"></span><span class="base textstyle uncramped"><span class="mrel">≤</span><span class="mord mathrm">5</span><span class="mord mathrm">0</span></span></span></span>), and then followed by <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> lines of projects, each contains three numbers <span class="katex"><span class="katex-mathml"><math><mrow><mi>P</mi></mrow>P</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.13889em;">P</span></span></span></span>, <span class="katex"><span class="katex-mathml"><math><mrow><mi>L</mi></mrow>L</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">L</span></span></span></span>, and <span class="katex"><span class="katex-mathml"><math><mrow><mi>D</mi></mrow>D</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.02778em;">D</span></span></span></span> where <span class="katex"><span class="katex-mathml"><math><mrow><mi>P</mi></mrow>P</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.13889em;">P</span></span></span></span> is the profit, <span class="katex"><span class="katex-mathml"><math><mrow><mi>L</mi></mrow>L</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">L</span></span></span></span> the lasting days of the project, and <span class="katex"><span class="katex-mathml"><math><mrow><mi>D</mi></mrow>D</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.02778em;">D</span></span></span></span> the deadline. It is guaranteed that <span class="katex"><span class="katex-mathml"><math><mrow><mi>L</mi></mrow>L</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">L</span></span></span></span> is never more than <span class="katex"><span class="katex-mathml"><math><mrow><mi>D</mi></mrow>D</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.02778em;">D</span></span></span></span>, and all the numbers are non-negative integers.</p>
<h3 id="output-specification-">Output Specification:</h3>
<p>For each test case, output in a line the maximum profit you can gain.</p>
<h3 id="sample-input-">Sample Input:</h3>
<pre><code class="lang-in">4
7 1 3
10 2 3
6 1 2
5 1 1
</code></pre>
<h3 id="sample-output-">Sample Output:</h3>
<pre><code class="lang-out">18
</code></pre>
</div>