Codeforces Round #273 (Div. 2) C Table Decorations_html/css_WEB-ITnose
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 r, g 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 r, g 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
input
1 1 1
output
input
2 3 3
output
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.
解题思路:用三种颜色的气球装饰桌子,每个桌子装饰三个气球,并且规定每个桌子不能只用一种颜色的气球装饰,给出三种颜色气球的的个数,求最多可以装饰多少个桌子。
很显然,讨论一下,两种较少的气球的个数的和是否小于最多气球的个数的一半,若小于,则每个桌子用两个个数最多的气球,再加上另两种气球中的任一个即可;若不小于,则最大值为三种气球的总个数的平均数。
AC代码:
#include#include #include #include #include #include #include #include
推荐阅读
-
Codeforces Round #649 (Div. 2) C-Ehab and Prefix MEXs
-
Codeforces Round #432 (Div. 2) - C - Five Dimensional Points
-
Codeforces Round #658 (Div. 2)C1. Prefix Flip (Easy Version)(贪心)
-
Codeforces Round #658 (Div. 2) (C1、C2)
-
Codeforces Round #320 (Div. 2) C. A Problem about Polyline ( 数学 )
-
Codeforces Round #659 (Div. 2) C、String Transformation 1(思维+set)
-
Codeforces Round #654 (Div. 2)-C. A Cookie for You
-
Educational Codeforces Round 85 (Rated for Div. 2) C. Circle of Monsters(前缀和 预处理 贪心)
-
Codeforces Round #651 (Div. 2) C. Number Game
-
Codeforces Round #666 (Div. 2)C - Multiples of Length(错位相减)