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