File size: 1,719 Bytes
761e24d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<p>
Alex's New Year's resolution for 2015 is to eat healthier foods. He's done some
research and has found out that calories come from three main sources, called
macronutrients: protein, carbohydrates, and fat. Alex wants to get the right
balance of protein, carbohydrates, and fat to have a balanced diet.
For each available food, Alex can only choose to eat it or not eat it. He
can't eat a certain food more than once, and he can't eat a fractional amount
of a food.
</p>
<h3>Input</h3>
<p>
Input begins with an integer <strong>T</strong>, the number of test cases.
For each test case, the first line consists of three space-separated
integers: <strong>G<sub>P</sub></strong>,
<strong>G<sub>C</sub></strong>, and <strong>G<sub>F</sub></strong>,
which represent the amount of
protein, carbohydrates, and fat that Alex wants to eat. The next line has the number of foods for that test case, an integer <strong>N</strong>.
The next <strong>N</strong> lines each consist of three space-separated integers:
<strong>P</strong>, <strong>C</strong>, and <strong>F</strong>,
which represent the amount of protein, carbohydrates, and fat in that food, respectively.
</p>
<h3>Output</h3>
<p>
For each test case <em>i</em>, print a line containing "Case #<em>i</em>: " followed by
either "yes" if it is possible for Alex to eat the exact amount of each
macronutrient, or "no" if it is not possible.
</p>
<h3>Constraints</h3>
<p>
1 ≤ <strong>T</strong> ≤ 20 <br/>
1 ≤ <strong>N</strong> ≤ 20 <br/>
10 ≤ <strong>G<sub>P</sub></strong>, <strong>G<sub>C</sub></strong>,
<strong>G<sub>F</sub></strong> ≤ 1000 <br/>
10 ≤ <strong>P</strong>, <strong>C</strong>, <strong>F</strong> ≤ 1000 <br/>
</p>
|