Codeforces Round #273 (Div. 2) C. Table Decorations Math

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.