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
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.

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

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

代码:

#include <iostream>
#include <cstdio>
#include <cstdio>
#include <algorithm>
using namespace std; int main()
{
long long a[3];
scanf("%I64d%I64d%I64d",&a[0],&a[1],&a[2]);
sort(a,a+3);
long long ans=0;
if((a[0]+a[1])<=a[2]/2)
{
ans=a[0]+a[1];
}
else
{
ans=(a[0]+a[1]+a[2])/3;
}
printf("%I64d\n",ans);
return 0;
}

最新文章

  1. ABP源码分析二十九:ABP.MongoDb
  2. SQLite的时候判断语句是否纯在:出现RuntimeException
  3. matlab函数大全
  4. String 与StringBuilder有什么区别
  5. Scalaz(52)- scalaz-stream: 并行运算-parallel processing concurrently by merging
  6. MapReduce编程示例
  7. Sqoop2入门之导入关系型数据库数据到HDFS上(sqoop2-1.99.4版本)
  8. 简单好用的日志管理工具 Logrotate
  9. [转]Eclipse Java注释模板设置详解
  10. jquery简单插件到复杂插件(3)--顶部导航固定
  11. 《Java编程那点事儿》读书笔记(一)——基本数据结构
  12. [CSS]text-decoration
  13. 项目中常用方法总结(将将DataTable数据集映射到实体对象)【转】
  14. Python - 定制pattern的string模板(template) 具体解释
  15. 字符串拼接 拆分 NameValueCollection qscoll = HttpUtility.ParseQueryString(result)
  16. 从零开始学安全(四十一)●初识Wireshark
  17. ueditor笔记
  18. ERP合同审核流程处理(二十九)
  19. 【Leetcode】292. Nim游戏
  20. (转)Spring Boot(一)

热门文章

  1. 转:JavaScript函数式编程(一)
  2. 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?
  3. Codeforces 325D
  4. wx.Dialog
  5. AngularJs(八) 过滤器filter创建
  6. Sql Server 列转行 Pivot使用
  7. CentOS6.3 下启动Oracle service和listener
  8. CentOS 6使用VNC配置远程桌面
  9. Js 自定义回调函数
  10. ecmall 点滴记录