C. Table Decorations
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

首先要明确,当最大的气球数量的一半小于另外两种颜色的数量之和,肯定能够组成所有颜色数量之和/3,当最大的

气球数量的一半大于等于另外两种颜色的数量之和,所有组成为2+1,2为最多数量的颜色。

代码:

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdio>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. long long a[3];
  10. scanf("%I64d%I64d%I64d",&a[0],&a[1],&a[2]);
  11. sort(a,a+3);
  12. long long ans=0;
  13. if((a[0]+a[1])<=a[2]/2)
  14. {
  15. ans=a[0]+a[1];
  16. }
  17. else
  18. {
  19. ans=(a[0]+a[1]+a[2])/3;
  20. }
  21. printf("%I64d\n",ans);
  22. return 0;
  23. }

C. Table Decorations(Codeforces Round 273)的更多相关文章

  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)C. Table Decorations 数学

    C. Table Decorations   You have r red, g green and b blue balloons. To decorate a single table for t ...

  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 #273 (Div. 2)

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

  7. 「日常训练」Watering Flowers(Codeforces Round #340 Div.2 C)

    题意与分析 (CodeForces 617C) 题意是这样的:一个花圃中有若干花和两个喷泉,你可以调节水的压力使得两个喷泉各自分别以\(r_1\)和\(r_2\)为最远距离向外喷水.你需要调整\(r_ ...

  8. 「日常训练」Alternative Thinking(Codeforces Round #334 Div.2 C)

    题意与分析 (CodeForces - 603A) 这题真的做的我头疼的不得了,各种构造样例去分析性质... 题意是这样的:给出01字符串.可以在这个字符串中选择一个起点和一个终点使得这个连续区间内所 ...

  9. 「日常训练」More Cowbell(Codeforces Round #334 Div.2 B)

    题意与分析(CodeForces 604B) 题意是这样的:\(n\)个数字,\(k\)个盒子,把\(n\)个数放入\(k\)个盒子中,每个盒子最多只能放两个数字,问盒子容量的最小值是多少(水题) 不 ...

随机推荐

  1. 为什么国外程序员爱用苹果 Mac 电脑?

      Mac 在国外很受欢迎,尤其是在 设计/web开发/IT 人员圈子里.普通用户喜欢 Mac 可以理解,毕竟 Mac 设计美观,简单好用,没有病毒.那么为什么专业人士也对 Mac 情有独钟呢?从个人 ...

  2. 利用 Windows Azure 实现“云优先”

    根据 IDC 的调查,云计算无疑为我们的合作伙伴提供了巨大的机会,预计到 2016 年,全球企业将在公共云服务上耗资 980 亿美元.在今天的休斯敦全球合作伙伴大会上,我们非常高兴能与合作伙伴共同寻求 ...

  3. Yii中的CCheckBoxColumn在widget中的用法

    'columns'=>array(        array(            'class'=>'CCheckBoxColumn',            'id'=>'us ...

  4. 图片处理之-Bitmap.Config,jpeg压缩与大小

    关于ARGB_8888.ALPHA_8.ARGB_4444.RGB_565的理解 A:透明度 R:红色 G:绿 B:蓝 Bitmap.Config ARGB_4444:每个像素占四位,即A=4,R=4 ...

  5. MSSQL查询连接数

    SELECT * FROM [Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT [DBID] FROM [Master].[dbo].[SYS ...

  6. 连接远程hbase长时间等待问题

    确保本地保存了远程主机名: 保存远程hosts

  7. char* 和 wchar_t* 如何互相转换

    char* 和 wchar_t* 如何互相转换 C函数可以用 wcstombs - 将宽字符转换成多字符 WCHAR ->  CHAR      mbstowcs - 把多字符把转换成宽字符 C ...

  8. JavaWeb核心编程之(三.2)Servlet配置

    Servlet配置 1.配置Serlvet加载时机 2.配置多映射 配置加载时机 新建项目config->创建包com.xiaoan.config->创建类FirstServlet imp ...

  9. Docker的C/S模式详解

    Docker的C/S模式 Docker的C/S模式 Docker Client通过Remote API与Docker Server通信: RESTful风格API STDIN.STDOUT.STDER ...

  10. perl正则表达式第一周笔记

    正则表达式基础 ^ 行首标志 $ 行末标志 如^cat即一整行只有cat这个单词,^则是一个空行 [  ] 字符组,用来匹配若干字符之一 如gr[ae]y,即grey或者gray - 在字符组内部,字 ...