Good Bye 2018 A

2018-12-31 01:36:03

# 题目链接：

https://codeforces.com/contest/1091/problem/A

# 原题：

Problem Statement

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.

Input

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.

Output

Print one number — the maximum number of ornaments that can be used.

Examples

input1

8 13 9

output1

24

input2

13 3 6

output2

9

Note

In the first example, the answer is 7+8+9=24.

In the second example, the answer is 2+3+4=9.

emm，是道水题。

# AC代码：

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
typedef long long ll;
#include<vector>
#define cin(n) scanf("%lld",&(n))
#define cout(n) printf("%lld",(n))
#define couc(c) printf("%c",(c))
#define coutn printf("\n")
#define cout_ printf(" ")
#define debug() printf("haha\n")
const int MAXN =1005;
ll t,n,k;
ll a[MAXN];
ll MIN=0x3f3f3f3f;
ll ans;
int MINNUM=1;
int main()
{
for(int i=1;i<=3;i++)
cin(a[i]);
if(a[2]-1<=a[1])
{
MINNUM=2;
}
if(a[3]-2<=a[1]&&a[3]-1<=a[2])
{
MINNUM=3;
}
if(MINNUM==1)
{
ans=a[1]*3+3;
}
else if(MINNUM==2)
{
ans=a[2]*3;
}
else{
ans=a[3]*3-3;
}
cout(ans);
return 0;
}
• star
首页