[Solution] Red Blue Flowers CodeChef Solution
Problem
Chef has a garden containing cells. The -th cell has red flowers and blue flowers. Chef can collect only one type of flowers (either red or blue) from each cell.
Let denote the total number of red flowers Chef collects and denote the total number of blue flowers Chef collects. Chef wants to maximize the value of . Can you help Chef?
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — the number of cells in Chef's garden.
- The second line of each test case contains space-separated integers denoting the number of red flowers in each cell.
- The third line of each test case contains space-separated integers denoting the number of blue flowers in each cell.
Output Format
For each test case, output the maximum value of .
Explanation:
Test case 1: If Chef collects red flower from the cell, Chef will have a total of red flower and blue flowers .
If Chef collects the blue flowers from the cell, Chef will have a total of red flowers and blue flowers .
Either way, , the answer is .
Test case 2: Chef collects the blue flowers from the first cell and the red flowers from the second cell, so , which is maximum.
Test case 3: Chef collects blue cells from the first three cells and red flowers from the fourth cell , so , which is maximum.
No comments:
Post a Comment