[Solution] Maximize Colours CodeChef Solution
Problem
For the human eye, primary colours are red, green, and blue.
Combining drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta.
You have and drops of red, green, and blue colours respectively. Find the maximum total number of distinct colours (both primary and secondary) you can have at any particular moment.
Note: You cannot mix a secondary colour with a primary or another secondary colour to get a new type of colour.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of three space separated integers and , the number of drops of red, green, and blue colours respectively.
Output Format
For each test case, output on a new line the maximum total number of colours (both primary and secondary) you can have using the given primary colours.
Explanation:
Test case : We have drop each of red and blue colour. If we mix these colours, we will have magenta but no red or blue. Thus, to maximize the total number of colours, it is better that we keep the red and blue colours as it is. The maximum number of colours we can have is .
Test case : We have drops each of red and green colour. We can use drop each of red and green to have yellow. We still have drops each of red and green left. Thus, we have different types of colours now.
Test case : If we mix any two colours, we will loose two colours and get only one colour in return. Thus, it is best to keep all colours as it is and keep different varieties of colours.
No comments:
Post a Comment