Peaceful Party solution codechef
The mayor of your city has decided to throw a party to gather the favour of his people in different regions of the city.
There aredistinct regions in the city namely , , comprising of , and number of people respectively.
However, the mayor knows that people of the regionare in conflict with people of regions and . So, there will be a conflict if people from region are present at the party along with people from region or .
The mayor wants to invite as many people as possible and also avoid any conflicts. Help him invite maximum number of people to the party.
- 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 three integers , and – number of people living in regions , and respectively.
For each test case, output the maximum number of people that can be invited to the party.
Sample Input 1
3 2 3 4 1 5 2 8 8 8
Sample Output 1
6 5 16
Test case-1: Mayor can invite all the people from regionand . So the maximum number of people invited is .
Test case-2: Mayor can invite all the people from region. So the maximum number of people invited is .