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 are 33 distinct regions in the city namely AA, BB, CC comprising of PAPA, PBPB and PCPC number of people respectively. However, the mayor knows that people of the region BB are in conflict with people of regions AA and CC. So, there will be a conflict if people from region BB are present at the party along with people from region AA or CC. 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.

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 are 33 distinct regions in the city namely AABBCC comprising of PAPAPBPB and PCPC number of people respectively.

However, the mayor knows that people of the region BB are in conflict with people of regions AA and CC. So, there will be a conflict if people from region BB are present at the party along with people from region AA or CC.

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.

Input Format

  • The first line contains a single integer TT – the number of test cases. Then the test cases follow.
  • The first line of each test case contains three integers PAPAPBPB and PCPC – number of people living in regions AABB and CC respectively.

Output Format

For each test case, output the maximum number of people that can be invited to the party.

Constraints

  • 1T10001≤T≤1000
  • 1PA,PB,PC10001≤PA,PB,PC≤1000

Sample Input 1 

3
2 3 4
1 5 2
8 8 8

Sample Output 1 

6
5
16

Explanation

Test case-1: Mayor can invite all the people from region AA and CC. So the maximum number of people invited is 66.

Test case-2: Mayor can invite all the people from region BB. So the maximum number of people invited is 55.

For Solution

Click Here!

 

 

Leave a Comment

Your email address will not be published.