Statistics

Problem Statement for "Vitamins"

Problem Statement

PROBLEM STATEMENT

Dr. Snimativ wants to prescribe vitamins to his patients. He wants to prescribe
as many vitamins as possible (to make the most money), but without danger of
killing his patients. The FDA has given a limit for the maximum amount (in
terms of the USRDA) of a particular vitamin someone can consume in a day
without a fatality. Dr. Snimativ has come across a particular multiple vitamin
supplement which is the only one he will prescribe. Given the amount of each
vitamin within the pills, and the USRDA for that vitamin, he needs to know how
many pills one can safely consume within a day.

DEFINITION

Class name: Vitamins
Method name: optimal
Parameters: int[], int[]
Returns: int

The method signature is: (make sure it is declared public)
int optimal(int[] percentages, int[] limit);

percentages contains the percentages of the USRDA for each vitamin in the
supplement.
limit contains the safe upper limit for each vitamin, where element 0 of limit
corresponds to element 0 of percentages, etc.

Your task is to determine the maximum number of pills someone can safely
consume without exceeding any of the limits.

TopCoder will enforce the following:
* percentages and limit will contain between 1 and 50 elements, inclusive.
* Each element of percentages will be between 1 and 100, inclusive.
* Each element of limit will be between 1 and 10000, inclusive.
* percentages and limit will contain the same number of elements.

Example 1:
percentages = {10, 20, 30, 5}
limit = {100, 150, 500, 50}
The maximum number of pills that can be safely consumed is 7.
consuming 7 pills yields 70% of the first vitamin, 140% of the second, 210% of
the third, and 35% of the fourth. None of these exceed the given limits.
Consuming 8 pills would yield 80% of the first, 160% of the second - but this
exceeds the 150% limit given, and thus is too many.
Method returns 7.

Example 2:
percentages = {100, 100, 100, 15}
limit = {10000, 9000, 8000, 299}
The maximum number of pills is 19, since 20 would put the fourth vitamin at
300%, which is over the 299% limit.
Method returns 19.

Example 3:
percentages = {1, 2, 3, 4}
limit = {100, 100, 100, 100}
Method returns 25.

Example 4:
percentages = {11, 13, 17, 19}
limit = {100, 100, 100, 100}
Method returns 5.

Definition

Class:
Vitamins
Method:
optimal
Parameters:
int[], int[]
Returns:
int
Method signature:
int optimal(int[] param0, int[] param1)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: