| <p> | |
| Wilson works for a moving company. His primary duty is to load household items into a moving truck. | |
| Wilson has a bag that he uses to move these items. He puts a bunch of items in the bag, moves them | |
| to the truck, and then drops the items off. | |
| </p> | |
| <p> | |
| Wilson has a bit of a reputation as a lazy worker. Julie is Wilson's supervisor, and she's keen to make sure | |
| that he doesn't slack off. She wants Wilson to carry at least 50 pounds of items in his bag every time he | |
| goes to the truck. | |
| </p> | |
| <p> | |
| Luckily for Wilson, his bag is opaque. When he carries a bagful of items, Julie can tell how many items are | |
| in the bag (based on the height of the stack in the bag), and she can tell the weight of the top item. She can't, however, | |
| tell how much the other items in the bag weigh. | |
| She assumes that every item in the bag weighs at least as much as this top item, because surely Wilson, | |
| as lazy as he is, would at least not be so dense as to put heavier items on top of lighter ones. Alas, Julie is woefully | |
| ignorant of the extent of Wilson's lack of dedication to his duty, and this assumption is frequently incorrect. | |
| </p> | |
| <p> | |
| Today there are <strong>N</strong> items to be moved, and Wilson, paid by the hour as he is, wants to maximize the | |
| number of trips he makes to move all of them to the truck. What is the maximum number of trips Wilson can make | |
| without getting berated by Julie? | |
| </p> | |
| <p> | |
| Note that Julie is not aware of what items are to be moved today, and she is not keeping track of what Wilson has already | |
| moved when she examines each bag of items. She simply assumes that each bagful contains a total weight of at least | |
| <strong>k</strong> * <strong>w</strong> | |
| where <strong>k</strong> is the number of items in the bag, and <strong>w</strong> is the weight of the top item. | |
| </p> | |
| <h3>Input</h3> | |
| <p> | |
| Input begins with an integer <strong>T</strong>, the number of days Wilson "works" at his job. | |
| For each day, there is first a line containing the integer <strong>N</strong>. | |
| Then there are <strong>N</strong> lines, the <strong>i</strong>th of which contains a single integer, | |
| the weight of the <strong>i</strong>th item, <strong>W<sub>i</sub></strong>. | |
| </p> | |
| <h3>Output</h3> | |
| <p> | |
| For the <strong>i</strong>th day, print a line containing "Case #<strong>i</strong>: " followed by the maximum number | |
| of trips Wilson can take that day. | |
| </p> | |
| <h3>Constraints</h3> | |
| <p> | |
| 1 ≤ <strong>T</strong> ≤ 500 <br /> | |
| 1 ≤ <strong>N</strong> ≤ 100 <br /> | |
| 1 ≤ <strong>W<sub>i</sub></strong> ≤ 100 <br /> | |
| </p> | |
| <p> | |
| On every day, it is guaranteed that the total weight of all of the items is at least 50 pounds. | |
| </p> | |
| <h3>Explanation of Sample</h3> | |
| <p> | |
| In the first case, Wilson can make two trips by stacking a 30-pound item on top of a 1-pound item, | |
| making the bag appear to contain 60 pounds. | |
| </p> | |
| <p> | |
| In the second case, Wilson needs to put all the items in the bag at once and can only make one trip. | |
| </p> | |
| <p> | |
| In the third case, one possible solution is to put the items with odd weight in the bag for the first trip, | |
| and then the items with even weight in the bag for the second trip, making sure to put the heaviest item on top. | |
| </p> | |