B. Palindrome
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given three positive integers n
, m
, and k
, which represent the exact number of characters 0
, 1
, and 2
available, respectively. You want to construct the longest possible palindrome string S
using at most n
zeros, m
ones, and k
twos. Compute and print the maximum possible length
of such a palindrome. A palindromic string reads the same forward and backward. Few examples of such palindromes - 0, 1, 2, 11, 00, 101, 121 etc.
Input
- The first line contains a single integer
T
(1 ≤ T ≤ \(10^5\)), the number of test cases. - Each of the next
T
lines contains three space-separated integersn
,m
,k
.(1 ≤ n, m, k ≤ \(10^9\))
Output
- For each test: Print the length of longest palindrome string
S
you have made.
Sample
Input | Output |
---|---|
|
|
First test case :
String S="2120212", is a palindromic string. Where at most n=1 zero, m=2 ones and k=4 twos.
The length of the string S is 7 which is maximum.
Information
- ID
- 1195
- Difficulty
- 3
- Category
- (None)
- Tags
- (None)
- # Submissions
- 123
- Accepted
- 59
- Accepted Ratio
- 48%
- Uploaded By
Related
In following contests: