B. Ciel and Flowers

来源:互联网 发布:淘宝金酷娃消防车视频 编辑:程序博客网 时间:2024/05/22 11:45

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 rg 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;}