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 have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color?

Your task is to write a program that for given values rg and b will find the maximum number t of tables, that can be decorated in the required manner.

Input

The single line contains three integers rg and b (0 ≤ r, g, b ≤ 2·109) — the number of red, green and blue baloons respectively. The numbers are separated by exactly one space.

Output

Print a single integer t — the maximum number of tables that can be decorated in the required manner.

Sample test(s)
input
5 4 3
output
4
 
Note

In the first sample you 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.

题意:给你三种颜色的气球, 现在让你从中选出三个,满足:最多有两个气球的颜色是一样的。问你这样满足条件的方案数

题解:   我们来对三种气球的数量排序,从大到小a,b,c,

如果a/2>=b+c显然最多就是b+c;画个图,就知道了

那么就只有  (a+b+c)/3这种解了

///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define inf 1000000007
#define mod 1000000007
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){
if(ch=='-')f=-;ch=getchar();
}
while(ch>=''&&ch<=''){
x=x*+ch-'';ch=getchar();
}return x*f;
}
//************************************************
const int maxn=+;
ll c[maxn];
ll ans;
int main(){ for(int i=;i<=;i++){
scanf("%I64d",&c[i]);
}
sort(c+,c++);
if(c[]+c[]<=c[]/){
ans=c[]+c[];
}
else if(c[]+c[]<=c[]) {
ans=(c[]+c[]+c[])/;
}
else if(c[]+c[]>c[]){
ans=(c[]+c[]+c[])/;
}
cout<<ans<<endl;
return ;
}

代码

Codeforces Round #273 (Div. 2)C. Table Decorations 数学的更多相关文章

  1. 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations

    题目传送门 /* 贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr... ans = a[1] + a[2]; 或先2 ...

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

    http://codeforces.com/contest/478/problem/C C. Table Decorations time limit per test 1 second memory ...

  3. codeforces 的 Codeforces Round #273 (Div. 2) --C Table Decorations

    C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #273 (Div. 2)

    A. Initial Bet 题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况 #include<iostream> #include<cstdio> #incl ...

  5. Codeforces Round #273 (Div. 2) A , B , C 水,数学,贪心

    A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #345 (Div. 1) C. Table Compression dp+并查集

    题目链接: http://codeforces.com/problemset/problem/650/C C. Table Compression time limit per test4 secon ...

  7. Codeforces Round #345 (Div. 2) E. Table Compression 并查集

    E. Table Compression 题目连接: http://www.codeforces.com/contest/651/problem/E Description Little Petya ...

  8. codeforces Codeforces Round #345 (Div. 1) C. Table Compression 排序+并查集

    C. Table Compression Little Petya is now fond of data compression algorithms. He has already studied ...

  9. Codeforces Round #144 (Div. 2) D table

    CodeForces - 233D 题目大意给你一个n*m 的矩阵,要求你进行涂色,保证每个n*n的矩阵内都有k个点被涂色. 问你一共有多少种涂色方案. n<=100 && m& ...

随机推荐

  1. dutacm.club_1089_A Water Problem_(dp)

    题意:要获得刚好后n个'k'的字符串,有两种操作,1.花费x秒,增加或删除1个'k'; 2.花费y秒,使个数翻倍.问最少需要多少时间获得这个字符串. 思路:i为偶数个'k',dp[i]=min(dp[ ...

  2. ios 布局 素材 待整理

    https://www.cnblogs.com/fxwl/p/5961372.html div区域 8.盒子模型的相关属性 margin(外边距/边界) border(边框) padding(内边距/ ...

  3. 搭建jQuery开发环境

    每个版本又分为一下两种:开发版和生产版: 版本 大小/KB 描述jquery-1.x.js 约288 开发版,完整无压缩,多用于学习,开发和测试jquery-2.x.js 约251 开发版,完整无压缩 ...

  4. acedssget

    大多数ObjectARX函数在处理选择集和实体时,都用名字来识别选择集或实体,该名字用一个长整型对来表示的,并对AutoCAD来维护.在ObjectARX中,该名字的类型为ads_name.在对选择集 ...

  5. 微服务网关从零搭建——(九)网关部署到linux服务器

    环境准备 公司电脑已安装core环境所以此处略过core环境安装 可参看此处 consul安装 如果没有wget命令 执行以下命令 yum install wget 下载consul wget htt ...

  6. Autowired和Resource的区别

    Autowired是属于spring的注解,默认按类型装配,且依赖对象必须存在,如果允许为null,需要设置Autowired(required=false)   Resource属于javax,默认 ...

  7. Python学习第二阶段Day2,模块subprocess、 logging、re

    1.logging 日志开关,设置全局只打印什么级别的日子,默认是warning以下的都不打印 改默认级别:依次升高 logging.debug("") logging.info( ...

  8. A - Restaurant

    UVA 1468 Description   Mr. Kim is planning to open a new restaurant. His city is laid out as a grid ...

  9. PAT 1139 First Contact

    Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle i ...

  10. foreach获取访问元素的下标

    今天在用foreach循环的时候,要同时根据访问下标获取另一个list对象数据,之前想的方法是加一个变量i,然后每次i++,但是感觉这样不是很好!,后来发现这样也可以!举个简单的例子! foreach ...