Ciel and Flowers

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.

Input:

3 6 9

Out:

6

        题解:

        当三色花束为:a,b,c。且最小设为min1。

        其实为(1,1,1)的情况最多只有0,1,2种次数。

        如(6,7,7)的情况,注意(6,6,6)的部分 分开(3)与混合(1,1,1)的数量是相等的。

        因此先用三色花束都>3的部分任意构造花朵后。剩余的min1只有2种情况。

        (6,6,6) :min1 = 0;

      (7,8,8): min1 = 1;

        (8,8,10) : min1 = 2;

        并不是说分开(3)与混合(1,1,1)的数量是相等的,我们就要先把此部分全部构造完,只是提供一个概念,即无论何时,剩余的那个最小的一定是小于等于2的。就相当于 %3 嘛。

        因此我们只要枚举(1,1,1)混合花朵,次数为0,1,2就可以枚举所有情况。

#include<bits/stdc++.h>
#define int long long 
#define rep(i, a, b) for(int i = a; i <= b; ++ i)
#define per(i, a, b) for(int i = a; i >= b; -- i)
using namespace std;
const int N = 1e5 + 10,mod = 1e9 + 7;

void solve(){
	int ans = -1;
    int a,b,c; cin >> a >> b >> c;
    int min1 = min(a,b);min1 = min(min1,c);min1 = min(min1,2LL);
    rep(i,0,min1){
		int res = i , A = a-i,B = b-i,C = c-i; 
		res += A/3 + B/3 + C/3;
		ans = max(ans,res);
	}

    cout << ans << endl;
}
signed main(){
    int t=1;
//	 cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值