Juice (Small Input)
Time limit5sMemory limit512 MB
Given up to 10 guests with minimum fractions of three juices summing to 1, find the largest subset satisfiable by one mix.
- Level
Medium5 of 10
- Topics
- Brute force, Geometry, Greedy
- Solved
- No attempts yet
Problem
You are holding a party. The drink you serve is a mix of three juices, apple, banana, and carrot. Call them , , and .
You have to fix the fraction of the drink taken by each juice, , , and . All three are real numbers at least and satisfy . Your goal is to maximize the number of guests who like the drink.
Each guest has a minimum fraction they want for every one of the three juices. A guest likes the drink only when all three fractions in the drink are at least that guest's own minimum for that juice. If even one falls short, the guest does not like it.
Determine the largest number of guests you can satisfy with a single best choice of the drink.
Input
The first line contains the number of test cases .
Each test case follows in this form.
- The first line contains the number of guests .
- Each of the next lines contains one guest's minimum fractions , , and , separated by spaces. The three values are given in parts per ten thousand, that is, as integers on a scale where the whole drink is , and each lies between and . Also .
Limits
Output
For each test case, print one line in the form Case #X: Y, where is the test case number starting from and is the largest number of guests who like the drink. Print the lines in the order the test cases are given.
Notes
In the first test case of the example, each of the three guests wants the whole drink to be one single juice, so only one of them can be satisfied.
In the second test case you can pick any two of the three guests and satisfy both.
In the third test case, mixing exactly of each juice makes all five guests like the drink.