A12169 | New Year and the Christmas Ornament
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob are decorating a Christmas Tree.
Alice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.
In Bob's opinion, a Christmas Tree will be beautiful if:
- the number of blue ornaments used is greater by exactly $1$ than the number of yellow ornaments, and
- the number of red ornaments used is greater by exactly $1$ than the number of blue ornaments.
That is, if they have $8$ yellow ornaments, $13$ blue ornaments and $9$ red ornaments, we can choose $4$ yellow, $5$ blue and $6$ red ornaments ( $5=4+1$ and $6=5+1$ ).
Alice wants to choose as many ornaments as possible, but she also wants the Christmas Tree to be beautiful according to Bob's opinion.
In the example two paragraphs above, we would choose $7$ yellow, $8$ blue and $9$ red ornaments. If we do it, we will use $7+8+9=24$ ornaments. That is the maximum number.
Since Alice and Bob are busy with preparing food to the New Year's Eve, they are asking you to find out the maximum number of ornaments that can be used in their beautiful Christmas Tree!
It is guaranteed that it is possible to choose at least $6$ ( $1+2+3=6$ ) ornaments.
Alice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.
In Bob's opinion, a Christmas Tree will be beautiful if:
- the number of blue ornaments used is greater by exactly $1$ than the number of yellow ornaments, and
- the number of red ornaments used is greater by exactly $1$ than the number of blue ornaments.
That is, if they have $8$ yellow ornaments, $13$ blue ornaments and $9$ red ornaments, we can choose $4$ yellow, $5$ blue and $6$ red ornaments ( $5=4+1$ and $6=5+1$ ).
Alice wants to choose as many ornaments as possible, but she also wants the Christmas Tree to be beautiful according to Bob's opinion.
In the example two paragraphs above, we would choose $7$ yellow, $8$ blue and $9$ red ornaments. If we do it, we will use $7+8+9=24$ ornaments. That is the maximum number.
Since Alice and Bob are busy with preparing food to the New Year's Eve, they are asking you to find out the maximum number of ornaments that can be used in their beautiful Christmas Tree!
It is guaranteed that it is possible to choose at least $6$ ( $1+2+3=6$ ) ornaments.
输入格式
The only line contains three integers $y$ , $b$ , $r$ ( $1 \leq y \leq 100$ , $2 \leq b \leq 100$ , $3 \leq r \leq 100$ ) — the number of yellow, blue and red ornaments.
It is guaranteed that it is possible to choose at least $6$ ( $1+2+3=6$ ) ornaments.
It is guaranteed that it is possible to choose at least $6$ ( $1+2+3=6$ ) ornaments.
输出格式
Print one number — the maximum number of ornaments that can be used.
输入输出样例
输入 #1
8 13 9
输出 #1
24
输入 #2
13 3 6
输出 #2
9
In the first example, the answer is $7+8+9=24$ .
In the second example, the answer is $2+3+4=9$ .
In the second example, the answer is $2+3+4=9$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted