您的位置:首页 > 其它

B. Ciel and Flowers

2013-08-27 09:37 148 查看
time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Fox Ciel has some flowers: r red flowers, g green
flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:

To make a "red bouquet", it needs 3 red flowers.

To make a "green bouquet", it needs 3 green flowers.

To make a "blue bouquet", it needs 3 blue flowers.

To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower.

Help Fox Ciel to find the maximal number of bouquets she can make.

Input

The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109)
— the number of red, green and blue flowers.

Output

Print the maximal number of bouquets Fox Ciel can make.

Sample test(s)

input
3 6 9


output
6


input
4 4 4


output
4


input
0 0 0


output
0


Note

In test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.

In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.

解题说明:此题是一个排列组合问题,给出每朵花需要的材料和一堆原材料,要求最多得到多少朵花。首先应该是求混合得到的花的数目,然后再求单一颜色花的数目。

#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;

int main()
{
int a,b,c,ans;
cin>>a>>b>>c;
ans=min(a,min(b,c));
a-=ans;
b-=ans;
c-=ans;
if(a%3+b%3+c%3 == 4 && ans)
{
ans++;
}
ans+=a/3+b/3+c/3;
cout<<ans<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: