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;
}

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. C++实现线程池 .

    C++实现线程池. 欢迎转载,转载请注明原出处:http://blog.csdn.net/ithzhang/article/details/9020283 代码地址:https://github.co ...

  2. 【转】浅析terminal创建时ptmx和pts关系

      我们打开一个terminal,那么将会在devpts文件系统/dev/pts下创建一个对应的pts字符文件,该pts字符文件节点直接由/dev/ptmx节点的驱动函数ptmx_open()调用de ...

  3. 百度静态资源(JS)公共库

         例如: chosen http://apps.bdimg.com/libs/chosen/1.1.0/chosen.jquery.min.js   classlist http://apps ...

  4. centos6.5 eclipse C/C++开发环境

  5. 在magento中使用正则式

    $sqlCondition = "IFNULL(_table_name.value, _table_name_default.value) REGEXP '^[^a-zA-Z]'" ...

  6. POJ 3318 - Matrix Multiplication 第一次用随机化解决问题...

    随机化还是很厉害的...印象最深的是以前手写快排~~一般加个随机化会使耗时不受输入数据的..时间更加稳定 这个题是人品题了...开始交了好多遍都过不了..多交几次终于过了... Program: #i ...

  7. 项目积累——Blockingqueue,ConcurrentLinkedQueue,Executors

    背景 通过做以下一个小的接口系统gate,了解一下mina和java并发包里的东西.A系统为javaweb项目,B为C语言项目,gate是本篇须要完毕的系统. 需求 1. A为集群系统,并发较高,会批 ...

  8. 把war包放到Tomcat安装文件夹下,不能直接訪问的解决方式

    临床表现: Tomcat启动后首页能訪问(http://localhost:8080/). 将自己写的一个webprojectwar包放到Tomcat安装文件夹下的/webapps以下(比方hello ...

  9. Linux网桥介绍

    网桥的功能类似于二层交换机,作用都是划分冲突域,它们之前且一些细微的差别,此处不展开. Linux网桥作为一个特殊的网桥的实现,有一些自己的特点,因为没有看代码,只能从功能上简单分析一下.个人认为,L ...

  10. Java中如何把两个数组合并为一个

    在Java中,如何把两个String[]合并为一个? 看起来是一个很简单的问题.但是如何才能把代码写得高效简洁,却还是值得思考的.这里介绍四种方法,请参考选用. 一.apache-commons 这是 ...