Simple Task III

3.5

11 votes
Ad-Hoc, Mathematics, Open, Approved, Easy, Mathamatics
Problem

Description:
Name string is a string consisting of letters "R","K" and "V". Today Oz wants to design a name string in a beautiful manner. Actually Oz cannot insert these three letters arbitrary anywhere ,he has to follow some rules to make the name string look beautiful. First thing is that the name string should consist of at most two different letters. Secondly adjacent letters in name string must be different.

After this procedure Oz wants name string to be as long as possible. Given the number of "R","K" and "V" letters that you have initially ,help Oz to find the maximum length of name string that Oz can make.

Input :
The first line contains the number of test cases T . Each test case consists of three space separated integers - A,B and C representing number of "R" letters, number of "K" letters and number of "V" letters respectively.

Output :
For each test case T, output maximum length of name string that Oz can make.

Constraints :
1 <= T <=100
0 <= A,B,C <=106

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

For first sample : The longest name string possible is : VKVKV using 3 "V" letters and 2 "K" letters and its length is 5.

Editor Image

?