CF1091A.New Year and the Christmas Ornament
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
爱丽丝和鲍勃正在装饰一棵圣诞树。
爱丽丝希望圣诞树上只使用三种颜色的装饰品:黄色、蓝色和红色。他们分别有 y 个黄色装饰品、b 个蓝色装饰品和 r 个红色装饰品。
在鲍勃看来,一棵圣诞树是“美丽的”,当且仅当:
- 所使用的蓝色装饰品数量比黄色装饰品数量恰好多 1 个;
- 所使用的红色装饰品数量比蓝色装饰品数量恰好多 1 个。
即,若他们有 8 个黄色装饰品、13 个蓝色装饰品和 9 个红色装饰品,则我们可以选择 4 个黄色、5 个蓝色和 6 个红色装饰品(因为 5=4+1 且 6=5+1)。
爱丽丝希望尽可能多地使用装饰品,同时仍满足鲍勃所定义的“美丽”条件。
在上面两段所举的例子中,我们应选择 7 个黄色、8 个蓝色和 9 个红色装饰品。这样总共使用了 7+8+9=24 个装饰品,即为最大可能值。
由于爱丽丝和鲍勃正忙于准备除夕夜的美食,他们请你帮忙计算:他们的“美丽”圣诞树最多能使用多少个装饰品!
题目保证至少可以选出 6 个装饰品(即 1+2+3=6)。
输入格式
The only line contains three integers y, b, r (1≤y≤100, 2≤b≤100, 3≤r≤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.
唯一一行包含三个整数 y、b、r(1≤y≤100,2≤b≤100,3≤r≤100)——分别表示黄色、蓝色和红色装饰品的数量。
保证至少可以选择 6 个装饰品(1+2+3=6)。
输出格式
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.
在第一个例子中,答案是 7+8+9=24。
在第二个例子中,答案是 2+3+4=9。
输入解题思路,AI测评打分。不知道怎么写?