CF1849A.Morning Sandwich

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 bb pieces of bread, cc slices of cheese and hh slices of ham. What is the maximum number of layers his morning sandwich can have?

Monocarp 总是以一个美味的三明治开启他美好的早晨。Monocarp 制作的三明治总是由面包、奶酪和/或火腿组成。

一个三明治始终遵循如下结构:

  • 一片面包
  • 一片奶酪或一片火腿
  • 一片面包
  • …\dots
  • 一片奶酪或一片火腿
  • 一片面包

因此,三明治顶部和底部必定是面包,并且面包与夹心层交替出现,其中夹心层为一片奶酪或一片火腿。每一片面包、每一片奶酪或每一片火腿都称为一层(layer)。

今天 Monocarp 醒来后发现,他手头有 bb 片面包、cc 片奶酪和 hh 片火腿。那么,他今天的早餐三明治最多能有多少层?

输入格式

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

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

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例包含三个整数 b,cb, c 和 hh(2≤b≤1002 \le b \le 100;1≤c,h≤1001 \le c, h \le 100)—— 分别表示面包片数、奶酪片数和火腿片数。

输出格式

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

对于每个测试用例,输出一个整数——Monocarp 的早餐三明治最多能有多少层。

输入输出样例

  • 输入#1

    3
    2 1 1
    10 1 2
    3 7 8

    输出#1

    3
    7
    5

说明/提示

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.

在第一个测试用例中,Monocarp 可以制作一个三层三明治:要么是一片面包、一片奶酪、再加一片面包;要么是一片面包、一片火腿、再加一片面包。

在第二个测试用例中,Monocarp 拥有大量面包,但馅料不足。他可以制作一个由四片面包、一片奶酪和两片火腿组成的三明治。

在第三个测试用例中,情况相反——Monocarp 拥有大量馅料,但面包不足。例如,他可以制作一个由三片面包和两片奶酪组成的三明治。

输入解题思路,AI测评打分。不知道怎么写?

首页