C. Table decorations
You have r Red, g Green and b Blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn ' t has the same color. What maximum number t of tables can is decorated if we know number of balloons of each color?
Your task is to write a program this for given values r, g and b would find The maximum number t of tables, that can is decorated in the required manner.
Input
The single line contains three integers r, g and b (0≤ R, G, b ≤2 109)-the number of red, green and blue baloons respectively. The numbers is separated by exactly one space.
Output
Print a single integer t -the Maximum number of tables The can is decorated in the required manner.
Sample Test (s) input
5 4 3
Output
4
Note
In the first sample can decorate the tables with the following balloon sets: "rgg", "gbb", "brr", "RRG ", where"R ","g "and"B "represent the red, green and blue balls, respectively.
Test Instructions : give you three kinds of color balloons, now let you choose three, satisfy: up to two balloons color is the same. Ask you how many scenarios that satisfy the criteria
A: Let's sort out the number of three balloons, from big to small a,b,c,
If A/2>=b+c is obviously the most b+c, draw a picture, you know.
then only (A+B+C)/3 of this solution
///1085422276#include <bits/stdc++.h>using namespacestd; typedefLong Longll;#defineMem (a) memset (A,0,sizeof (a))#defineMeminf (a) memset (A,127,sizeof (a));#defineINF 1000000007#defineMoD 1000000007inline ll read () {ll x=0, f=1;CharCh=GetChar (); while(ch<'0'|| Ch>'9'){ if(ch=='-') f=-1; ch=GetChar (); } while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar (); }returnx*F;}//************************************************Const intmaxn=20000+5; ll c[maxn];ll ans;intMain () { for(intI=1; i<=3; i++) {scanf ("%i64d",&C[i]); } sort (c+1, c+3+1); if(c[1]+c[2]<=c[3]/2) {ans=c[1]+c[2]; } Else if(c[1]+c[2]<=c[3]) {ans= (c[1]+c[2]+c[3])/3; } Else if(c[1]+c[2]>c[3]) {ans= (c[1]+c[2]+c[3])/3; } cout<<ans<<Endl; return 0;}
Code
Codeforces Round #273 (Div. 2) C. Table Decorations Math