SausagesProductionScheduler
TCCC07 Sponsor 4 · 2007-07-30 · by Mike Mirzayanov
Problem Statement
You have several recipes for sausages, each of which use the same two ingredients, but possibly in different ratios. Each recipe contains a lower and upper bound for the percentage of each ingredient. This means you can use any percentages for the two ingredients as long as they add up to 100% and fall within the specified inclusive bounds.
The recipes are given as two
You are given a
Constraints
- lowerPercentage will contain between 1 and 50 elements, inclusive.
- upperPercentage will contain the same number of elements as lowerPercentage.
- Each element of lowerPercentage and upperPercentage will consist of exactly two integers separated by a single space.
- Each integer in lowerPercentage and upperPercentage will be between 1 and 100, inclusive.
- Each integer in lowerPercentage will be less than or equal to the corresponding integer in upperPercentage.
- Each integer in lowerPercentage and upperPercentage will contain no leading zeroes.
- limits will contain exactly two elements.
- Each element of limits will be between 0 and 5000, inclusive.
{"50 50"}
{"50 50"}
{100, 100}
Returns: 1
Only one sausage per recipe.
{"41 33"}
{"57 40"}
{100, 150}
Returns: 0
You can't make a sausage using this recipe.
{"40 21", "6 10"}
{"89 71", "87 62"}
{54, 69}
Returns: 1
You can make one sausage using either recipe, but not both.
{"66 11", "9 11", "13 4"}
{"85 70", "28 41", "29 88"}
{280, 190}
Returns: 2
{"39 19", "6 68", "62 28"}
{"64 78", "41 86", "72 98"}
{230, 232}
Returns: 3
Submissions are judged against all 130 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class SausagesProductionScheduler with a public method int maxCount(vector<string> lowerPercentage, vector<string> upperPercentage, vector<int> limits) · 130 test cases · 2 s / 256 MB per case