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
input
1 1 1
output
1
input
2 3 3
output
2
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.

分析:

1.首先排序,

2.如果前两者之和的两倍小于第三者。那么个数就是前两者之和的个数

3.如果前两者之和的两倍大于第三者。我们可以这么想,先用第三者与前两者2:1平衡掉,然后前两者2:1一直走。也就是总数除以三

 #include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
long long a[];
scanf("%lld%lld%lld",&a[],&a[],&a[]);
sort(a,a+);
if((a[]+a[])*<=a[])
{
printf("%d\n",a[]+a[]);
}
else
{
printf("%d\n",(a[]+a[]+a[])/);
}
}

CF-478C的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  4. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  5. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  6. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  7. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  8. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  9. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

  10. CF #374 (Div. 2) D. 贪心,优先队列或set

    1.CF #374 (Div. 2)   D. Maxim and Array 2.总结:按绝对值最小贪心下去即可 3.题意:对n个数进行+x或-x的k次操作,要使操作之后的n个数乘积最小. (1)优 ...

随机推荐

  1. SCUT - 249 - Hello World - 数位dp

    https://scut.online/p/249 数位dp的模板题? 需要特殊判断0,这个很不优雅,因为0-1=-1是个很奇葩的东西? #include<bits/stdc++.h> u ...

  2. 洛谷 - P1987 - 摇钱树 - dp - 贪心

    https://www.luogu.org/problemnew/show/P1987 这道题,假如是n==k,也就是把所有的树都砍完,我就知道要贪心去做,因为树给的初始金币是固定的,每天掉金币,当然 ...

  3. Thirft 客户端等待时间

    thrift框架使用C++ thrift shows CLOSE_WAIL error thrift中TNonblockingServer的简单用法

  4. bzoj 1477: 青蛙的约会【exgcd】

    列出式子是\( mx+s1\equiv nx+s2(mod L) (m-n)x+Ly=s2-s1 \),注意如果n-m<0的话,就把ac都乘-1变成正数,然后exgcd求解,最后注意x为负的话要 ...

  5. Luogu P1542包裹快递【实数域二分】 By cellur925

    题目传送门 题目中说:最大值最小,显然是一个二分答案嘛qwq. 我们二分的答案显然是速度,但是由于实际中每一段的速度可能不同,所以这里我们把所有段进行的速度都定为二分出的答案. 二分的步骤好说,只是c ...

  6. 手把手教你如何在Fire fox火狐浏览器里在线识别下载视频(超强大)(博主推荐)

    网址是 Firefox about:addons

  7. Python标准库 re

    正则表达式 regular expression 用来匹配一系列符合句法规则的字符串,是一门独立的小型的语言,如果你了解类Unix系统,那么你对正则表达式就一定不陌生.正则表达式的概念最初是由Unix ...

  8. 递推DP HDOJ 5092 Seam Carving

    题目传送门 /* 题意:从上到下,找最短路径,并输出路径 DP:类似数塔问题,上一行的三个方向更新dp,路径输出是关键 */ #include <cstdio> #include < ...

  9. PopupWindow(2)简单示例-自定义弹出菜单

    本示例,用 popupWindow 自定义弹出菜单 public class CustomActionProvider extends ActionProvider implements OnMenu ...

  10. Spring-bean(二)

    命名空间 自动装配 bean之间的关系:继承:依赖 使用外部属性文件 SpEL bean的生命周期 bean的后置处理器 (一)util命名空间 当用list,set等集合时,不能将集合作为独立的be ...