310541: CF1849A. Morning Sandwich

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Morning Sandwichtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp always starts his morning with a good ol' sandwich. Sandwiches Monocarp makes always consist of bread, cheese and/or ham.

A sandwich always follows the formula:

  • a piece of bread
  • a slice of cheese or ham
  • a piece of bread
  • $\dots$
  • a slice of cheese or ham
  • a piece of bread

So it always has bread on top and at the bottom, and it alternates between bread and filling, where filling is a slice of either cheese or ham. Each piece of bread and each slice of cheese or ham is called a layer.

Today Monocarp woke up and discovered that he has $b$ pieces of bread, $c$ slices of cheese and $h$ slices of ham. What is the maximum number of layers his morning sandwich can have?

Input

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of testcases.

Each testcase consists of three integers $b, c$ and $h$ ($2 \le b \le 100$; $1 \le c, h \le 100$) — the number of pieces of bread, slices of cheese and slices of ham, respectively.

Output

For each testcase, print a single integer — the maximum number of layers Monocarp's morning sandwich can have.

ExampleInput
3
2 1 1
10 1 2
3 7 8
Output
3
7
5
Note

In the first testcase, Monocarp can arrange a sandwich with three layers: either a piece of bread, a slice of cheese and another piece of bread, or a piece of bread, a slice of ham and another piece of bread.

In the second testcase, Monocarp has a lot of bread, but not too much filling. He can arrange a sandwich with four pieces of bread, one slice of cheese and two slices of ham.

In the third testcase, it's the opposite — Monocarp has a lot of filling, but not too much bread. He can arrange a sandwich with three pieces of bread and two slices of cheese, for example.

Input

题意翻译

吃货小 C 喜欢三明治,他有三种材料:面包、芝士、火腿。正确的三明治组合应为一层面包和一层芝士或火腿之一轮流放置,以面包为结尾,例如面包-芝士-面包-火腿-面包就是合法的三明治。 给定每次做三明治的材料:$ b $ 面包,$ c $ 芝士,$ h $ 汉堡,求出小 C 最多做多少层三明治。 **多测**,$ t $ 组数据。 $ 1 \le t \le 1000 $,$ 2 \le b \le 100 $,$ 1 \le c,h \le 100 $。 翻译由 @[船酱魔王](/user/420998) 提供。

Output

题目大意:
Monocarp每天早上都从三明治开始他的一天。他的三明治总是由面包、奶酪和/或火腿组成。三明治的结构总是:一块面包,一片奶酪或火腿,交替进行,最后以一块面包结束。每个面包片和每片奶酪或火腿都称为一层。给定Monocarp拥有的面包片数b、奶酪片数c和火腿片数h,求他的三明治最多可以有多少层。

输入数据格式:
第一行包含一个整数t(1≤t≤1000)——测试用例的数量。
每个测试用例包含三个整数b、c和h(2≤b≤100;1≤c,h≤100)——面包片数、奶酪片数和火腿片数。

输出数据格式:
对于每个测试用例,输出一个整数——Monocarp的三明治最多可以有的层数。

示例:
输入
```
3
2 1 1
10 1 2
3 7 8
```
输出
```
3
7
5
```

注意:
- 在第一个测试用例中,Monocarp可以做一个有三层的三明治:一块面包,一片奶酪,再一块面包,或者一块面包,一片火腿,再一块面包。
- 在第二个测试用例中,Monocarp有很多面包,但填充物不多。他可以做一个有四块面包,一片奶酪和两片火腿的三明治。
- 在第三个测试用例中,情况相反——Monocarp有很多填充物,但面包不多。例如,他可以做有三块面包和两片奶酪的三明治。题目大意: Monocarp每天早上都从三明治开始他的一天。他的三明治总是由面包、奶酪和/或火腿组成。三明治的结构总是:一块面包,一片奶酪或火腿,交替进行,最后以一块面包结束。每个面包片和每片奶酪或火腿都称为一层。给定Monocarp拥有的面包片数b、奶酪片数c和火腿片数h,求他的三明治最多可以有多少层。 输入数据格式: 第一行包含一个整数t(1≤t≤1000)——测试用例的数量。 每个测试用例包含三个整数b、c和h(2≤b≤100;1≤c,h≤100)——面包片数、奶酪片数和火腿片数。 输出数据格式: 对于每个测试用例,输出一个整数——Monocarp的三明治最多可以有的层数。 示例: 输入 ``` 3 2 1 1 10 1 2 3 7 8 ``` 输出 ``` 3 7 5 ``` 注意: - 在第一个测试用例中,Monocarp可以做一个有三层的三明治:一块面包,一片奶酪,再一块面包,或者一块面包,一片火腿,再一块面包。 - 在第二个测试用例中,Monocarp有很多面包,但填充物不多。他可以做一个有四块面包,一片奶酪和两片火腿的三明治。 - 在第三个测试用例中,情况相反——Monocarp有很多填充物,但面包不多。例如,他可以做有三块面包和两片奶酪的三明治。

加入题单

上一题 下一题 算法标签: